/* ==================================================================
 * Smart Attendance — Professional PHIMS-style Frontend
 * Color palette: Teal #006666, White, Light Gray
 * ================================================================== */

/* ---------- Reset & Base ---------- */
.sa-app *,
.sa-app *::before,
.sa-app *::after {
        box-sizing: border-box;
}

.sa-app {
        font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
        margin: 0;
        padding: 0;
        line-height: 1.6;
        color: #333;
        max-width: 100%;
}

/* ---------- Full-page background ---------- */
.sa-app-wrapper {
        min-height: 100vh;
        background: #0a1628;
        background-image: url('../images/phims_BG.png');
        background-size: cover;
        background-position: center;
        background-attachment: fixed;
        position: relative;
}

.sa-app-wrapper::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, rgba(0, 50, 80, 0.85) 0%, rgba(0, 102, 102, 0.75) 50%, rgba(0, 40, 70, 0.85) 100%);
        z-index: 0;
}

.sa-app-inner {
        position: relative;
        z-index: 1;
        max-width: 960px;
        margin: 0 auto;
        padding: 20px 16px 40px;
}

/* ---------- Header with Logos ---------- */
.sa-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 18px 28px;
        background: rgba(255, 255, 255, 0.97);
        border-radius: 14px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
        margin-bottom: 24px;
}

.sa-header-left {
        display: flex;
        align-items: center;
        gap: 16px;
}

.sa-header-right {
        display: flex;
        align-items: center;
        gap: 16px;
}

.sa-header-logo {
        height: 60px;
        width: auto;
        object-fit: contain;
        border-radius: 4px;
}

.sa-header-title-group {
        display: flex;
        flex-direction: column;
        gap: 2px;
}

.sa-header-title {
        font-size: 20px;
        font-weight: 700;
        color: #006666;
        margin: 0;
        line-height: 1.3;
}

.sa-header-subtitle {
        font-size: 12px;
        color: #777;
        margin: 0;
        font-weight: 400;
}

/* ---------- Cards ---------- */
.sa-card {
        background: rgba(255, 255, 255, 0.97);
        border: none;
        border-radius: 14px;
        padding: 28px;
        margin-bottom: 24px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
        transition: box-shadow 0.3s ease;
}

.sa-card:hover {
        box-shadow: 0 6px 32px rgba(0, 0, 0, 0.18);
}

.sa-card h3 {
        margin: 0 0 6px;
        font-size: 18px;
        font-weight: 700;
        color: #006666;
        padding-bottom: 12px;
        border-bottom: 2px solid #e8f4f4;
}

.sa-card h3 .sa-card-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: linear-gradient(135deg, #006666, #008080);
        border-radius: 8px;
        margin-right: 10px;
        vertical-align: middle;
}

.sa-card h3 .sa-card-icon svg {
        width: 18px;
        height: 18px;
        fill: #fff;
}

/* ---------- Status Text ---------- */
.sa-status-text {
        font-size: 14px;
        color: #555;
        padding: 10px 0;
        margin: 0;
}

/* ---------- Assignment Banner ---------- */
.sa-assignment-banner {
        background: #e8f8f5;
        border: 1px solid #a3d9cc;
        border-radius: 10px;
        padding: 14px 18px;
        margin-bottom: 20px;
        font-size: 13px;
        color: #006666;
        line-height: 1.6;
}

.sa-assignment-banner strong {
        color: #004d4d;
}

.sa-assignment-banner ul {
        margin: 6px 0 0 18px;
        padding: 0;
}

.sa-assignment-banner li {
        margin-bottom: 2px;
}

.sa-assignment-banner.sa-error {
        background: #fef0ef;
        border-color: #f3a6a4;
        color: #a11e1e;
}

/* ---------- Camera Section ---------- */
.sa-camera-section {
        text-align: center;
        padding: 16px 0;
}

.sa-camera-section video,
.sa-camera-section canvas {
        display: none;
        max-width: 100%;
        border-radius: 12px;
        margin: 0 auto;
        box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
        object-fit: cover;
        background: #000;
}

.sa-camera-section img {
        display: none;
        max-width: 100%;
        border-radius: 12px;
        margin: 0 auto;
        box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
        border: 3px solid #e8f4f4;
        object-fit: cover;
        background: #000;
}

/* ---------- Buttons ---------- */
.sa-actions {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
        margin-top: 16px;
        justify-content: center;
}

.sa-actions .button,
.sa-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 10px 22px;
        border: 2px solid transparent;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.25s ease;
        text-decoration: none;
        line-height: 1.4;
        min-height: 42px;
}

.sa-btn-camera {
        background: #f0f7f7;
        color: #006666;
        border-color: #b2d8d8;
}

.sa-btn-camera:hover:not(:disabled) {
        background: #e0efef;
        border-color: #006666;
}

.sa-btn-capture {
        background: #ff9800;
        color: #fff;
        border-color: #e68a00;
}

.sa-btn-capture:hover:not(:disabled) {
        background: #e68a00;
}

.sa-btn-checkin {
        background: linear-gradient(135deg, #006666, #008080);
        color: #fff;
        border-color: #004d4d;
        box-shadow: 0 2px 8px rgba(0, 102, 102, 0.3);
}

.sa-btn-checkin:hover:not(:disabled) {
        background: linear-gradient(135deg, #004d4d, #006666);
        box-shadow: 0 4px 12px rgba(0, 102, 102, 0.4);
        transform: translateY(-1px);
}

.sa-btn-checkout {
        background: linear-gradient(135deg, #d35400, #e67e22);
        color: #fff;
        border-color: #a04000;
        box-shadow: 0 2px 8px rgba(211, 84, 0, 0.3);
}

.sa-btn-checkout:hover:not(:disabled) {
        background: linear-gradient(135deg, #a04000, #d35400);
        box-shadow: 0 4px 12px rgba(211, 84, 0, 0.4);
        transform: translateY(-1px);
}

.sa-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
}

/* Override WP default button styles inside our container */
.sa-app .button,
.sa-app .button-primary {
        border-radius: 8px !important;
        font-weight: 600 !important;
        padding: 10px 22px !important;
        min-height: 42px !important;
        font-size: 14px !important;
        transition: all 0.25s ease !important;
}

.sa-app .button-primary {
        background: linear-gradient(135deg, #006666, #008080) !important;
        border-color: #004d4d !important;
        box-shadow: 0 2px 8px rgba(0, 102, 102, 0.3) !important;
}

.sa-app .button-primary:hover {
        background: linear-gradient(135deg, #004d4d, #006666) !important;
}

/* ---------- Messages ---------- */
.sa-message {
        color: #d63638;
        font-size: 13px;
        min-height: 20px;
        padding: 8px 0;
        text-align: center;
        font-weight: 500;
}

.sa-message:empty {
        display: none;
}

/* ---------- User Welcome Bar ---------- */
.sa-welcome-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 20px;
        background: rgba(255, 255, 255, 0.95);
        border-radius: 12px;
        margin-bottom: 20px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.sa-welcome-bar .sa-welcome-text {
        font-size: 15px;
        font-weight: 600;
        color: #006666;
}

.sa-welcome-bar .sa-welcome-text span {
        color: #333;
        font-weight: 400;
}

.sa-welcome-bar .sa-live-clock {
        font-size: 22px;
        font-weight: 700;
        color: #006666;
        font-variant-numeric: tabular-nums;
        letter-spacing: 0.5px;
}

.sa-welcome-bar .sa-live-date {
        font-size: 12px;
        color: #888;
        text-align: right;
}

/* ---------- Quick Stats Row ---------- */
.sa-stats-row {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        margin-bottom: 24px;
}

.sa-stat-card {
        background: rgba(255, 255, 255, 0.95);
        border-radius: 12px;
        padding: 18px 16px;
        text-align: center;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
        border-top: 3px solid #006666;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sa-stat-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.sa-stat-card.sa-stat-late {
        border-top-color: #f39c12;
}

.sa-stat-card.sa-stat-absent {
        border-top-color: #e74c3c;
}

.sa-stat-card.sa-stat-leave {
        border-top-color: #3498db;
}

.sa-stat-value {
        font-size: 28px;
        font-weight: 800;
        color: #006666;
        line-height: 1.2;
}

.sa-stat-card.sa-stat-late .sa-stat-value {
        color: #f39c12;
}

.sa-stat-card.sa-stat-absent .sa-stat-value {
        color: #e74c3c;
}

.sa-stat-card.sa-stat-leave .sa-stat-value {
        color: #3498db;
}

.sa-stat-label {
        font-size: 12px;
        color: #888;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-top: 4px;
}

/* ---------- History Table ---------- */
.sa-history-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 16px;
}

.sa-history-header h3 {
        margin: 0 !important;
        padding-bottom: 0 !important;
        border-bottom: none !important;
}

.sa-export-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: linear-gradient(135deg, #006666, #008080) !important;
        color: #fff !important;
        border: none;
        border-radius: 8px;
        padding: 8px 16px;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.25s ease;
        box-shadow: 0 2px 8px rgba(0, 102, 102, 0.3);
}

.sa-export-btn:hover {
        background: linear-gradient(135deg, #004d4d, #006666) !important;
        box-shadow: 0 4px 12px rgba(0, 102, 102, 0.4);
        transform: translateY(-1px);
}

.sa-export-icon {
        flex-shrink: 0;
}

.sa-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 10px;
        border: 1px solid #e8efef;
}

.sa-table {
        width: 100%;
        border-collapse: collapse;
        margin: 0;
        font-size: 14px;
}

.sa-table thead th {
        background: linear-gradient(135deg, #006666, #008080);
        color: #fff;
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        padding: 12px 14px;
        text-align: left;
        white-space: nowrap;
        position: sticky;
        top: 0;
        z-index: 2;
}

.sa-table thead th:first-child {
        border-radius: 9px 0 0 0;
}

.sa-table thead th:last-child {
        border-radius: 0 9px 0 0;
}

.sa-table tbody td {
        padding: 11px 14px;
        border-bottom: 1px solid #f0f5f5;
        font-size: 13px;
        color: #444;
        white-space: nowrap;
}

.sa-table tbody tr:nth-child(even) {
        background: #f9fcfc;
}

.sa-table tbody tr:hover {
        background: #e8f4f4;
        transition: background 0.2s ease;
}

.sa-table tbody tr:last-child td {
        border-bottom: none;
}

/* ---------- Badges ---------- */
.sa-badge {
        padding: 4px 12px;
        border-radius: 20px;
        font-size: 11px;
        font-weight: 700;
        text-transform: capitalize;
        display: inline-block;
        letter-spacing: 0.3px;
}

.sa-badge-present          { background: #d4edda; color: #155724; }
.sa-badge-late             { background: #fff3cd; color: #856404; }
.sa-badge-absent           { background: #f8d7da; color: #721c24; }
.sa-badge-pending          { background: #fff3cd; color: #856404; }
.sa-badge-approved         { background: #d4edda; color: #155724; }
.sa-badge-rejected         { background: #f8d7da; color: #721c24; }
.sa-badge-full_day         { background: #d4edda; color: #155724; text-transform: none; }
.sa-badge-half_day         { background: #fff3cd; color: #856404; text-transform: none; }
.sa-badge-full_day_leave   { background: #d1ecf1; color: #0c5460; text-transform: none; }
.sa-badge-half_day_leave   { background: #e2d9f3; color: #4b2a8a; text-transform: none; }
.sa-badge-leave-approved   { background: #d1ecf1; color: #0c5460; text-transform: none; font-size: 11px; }

/* ---------- Cell Modifiers ---------- */
.sa-cell-date { min-width: 70px; }
.sa-cell-day  { min-width: 80px; }
.sa-cell-leave small { color: #555; font-weight: 400; }
.sa-cell-low-duty {
        color: #721c24 !important;
        font-weight: 700;
        background: #fde2e1;
        border-radius: 4px;
        padding: 2px 8px !important;
}

.sa-row-sunday { background: #fafafa !important; }
.sa-row-sunday td:first-child { color: #aaa; }

.sa-loading {
        text-align: center;
        color: #999;
        padding: 30px 8px !important;
        font-style: italic;
        font-size: 14px;
}

/* ---------- Leave Form ---------- */
.sa-leave-form-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
        margin-top: 16px;
}

.sa-form-group {
        display: flex;
        flex-direction: column;
        gap: 6px;
}

.sa-form-group label {
        font-size: 13px;
        font-weight: 600;
        color: #555;
        text-transform: uppercase;
        letter-spacing: 0.3px;
}

.sa-form-group select,
.sa-form-group input[type="date"],
.sa-form-group textarea {
        width: 100%;
        padding: 10px 14px;
        border: 1px solid #d1d9d9;
        border-radius: 8px;
        font-size: 14px;
        color: #333;
        background: #fafcfc;
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
        min-width: unset;
        font-family: inherit;
}

.sa-form-group select:focus,
.sa-form-group input[type="date"]:focus,
.sa-form-group textarea:focus {
        outline: none;
        border-color: #006666;
        box-shadow: 0 0 0 3px rgba(0, 102, 102, 0.1);
        background: #fff;
}

.sa-form-group textarea {
        resize: vertical;
        min-height: 80px;
}

.sa-form-full {
        grid-column: 1 / -1;
}

.sa-leave-submit-row {
        grid-column: 1 / -1;
        text-align: center;
        margin-top: 8px;
}

.sa-leave-submit-row .sa-btn {
        background: linear-gradient(135deg, #006666, #008080);
        color: #fff;
        border-color: #004d4d;
        padding: 12px 36px;
        font-size: 15px;
        box-shadow: 0 2px 8px rgba(0, 102, 102, 0.3);
}

.sa-leave-submit-row .sa-btn:hover {
        background: linear-gradient(135deg, #004d4d, #006666);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 102, 102, 0.4);
}

/* ---------- Standalone view tweaks ---------- */
.sa-standalone-view {
        max-width: 100%;
        margin: 0 auto;
        font-family: inherit;
}

/* ---------- Footer ---------- */
.sa-footer {
        text-align: center;
        padding: 20px 0 0;
        color: rgba(255, 255, 255, 0.7);
        font-size: 12px;
}

.sa-footer a {
        color: rgba(255, 255, 255, 0.9);
        text-decoration: none;
}

/* ==================================================================
 * RESPONSIVE DESIGN
 * ================================================================== */

/* Tablets */
@media (max-width: 768px) {
        .sa-app-inner {
                padding: 12px 10px 30px;
        }

        .sa-header {
                flex-direction: column;
                gap: 12px;
                padding: 16px 20px;
                text-align: center;
        }

        .sa-header-left,
        .sa-header-right {
                justify-content: center;
        }

        .sa-header-logo {
                height: 48px;
        }

        .sa-header-title {
                font-size: 17px;
        }

        .sa-header-subtitle {
                font-size: 11px;
        }

        .sa-card {
                padding: 20px 16px;
                border-radius: 12px;
        }

        .sa-stats-row {
                grid-template-columns: repeat(3, 1fr);
                gap: 10px;
        }

        .sa-stat-card {
                padding: 14px 10px;
        }

        .sa-stat-value {
                font-size: 24px;
        }

        .sa-stat-label {
                font-size: 10px;
        }

        .sa-welcome-bar {
                flex-direction: column;
                gap: 8px;
                text-align: center;
                padding: 12px 16px;
        }

        .sa-welcome-bar .sa-live-date {
                text-align: center;
        }

        .sa-leave-form-grid {
                grid-template-columns: 1fr;
        }
}

/* Mobile phones */
@media (max-width: 480px) {
        .sa-app-inner {
                padding: 8px 6px 24px;
        }

        .sa-header {
                padding: 12px 14px;
                border-radius: 10px;
                margin-bottom: 14px;
        }

        .sa-header-left {
                gap: 10px;
        }

        .sa-header-logo {
                height: 40px;
        }

        .sa-header-title {
                font-size: 15px;
        }

        .sa-header-subtitle {
                font-size: 10px;
        }

        .sa-header-right .sa-header-logo {
                height: 36px;
        }

        .sa-card {
                padding: 16px 12px;
                border-radius: 10px;
                margin-bottom: 14px;
        }

        .sa-card h3 {
                font-size: 16px;
                padding-bottom: 10px;
                margin-bottom: 4px;
        }

        .sa-card h3 .sa-card-icon {
                width: 28px;
                height: 28px;
                margin-right: 8px;
        }

        .sa-card h3 .sa-card-icon svg {
                width: 15px;
                height: 15px;
        }

        .sa-stats-row {
                grid-template-columns: repeat(3, 1fr);
                gap: 8px;
                margin-bottom: 14px;
        }

        .sa-stat-card {
                padding: 12px 8px;
                border-radius: 10px;
        }

        .sa-stat-value {
                font-size: 20px;
        }

        .sa-stat-label {
                font-size: 9px;
        }

        .sa-actions {
                flex-direction: column;
                gap: 8px;
        }

        .sa-actions .button,
        .sa-actions .sa-btn {
                width: 100%;
                justify-content: center;
                padding: 11px 20px;
        }

        .sa-camera-section img {
                max-width: 220px;
        }

        .sa-table thead th {
                padding: 10px 10px;
                font-size: 11px;
        }

        .sa-table tbody td {
                padding: 9px 10px;
                font-size: 12px;
        }

        .sa-history-header {
                flex-direction: column;
                align-items: stretch;
                gap: 12px;
        }

        .sa-export-btn {
                width: 100%;
                justify-content: center;
                padding: 10px 16px;
        }

        .sa-form-group select,
        .sa-form-group input[type="date"],
        .sa-form-group textarea {
                padding: 9px 12px;
                font-size: 16px; /* Prevent zoom on iOS */
        }

        .sa-welcome-bar .sa-live-clock {
                font-size: 18px;
        }

        .sa-badge {
                font-size: 10px;
                padding: 3px 8px;
        }

        .sa-assignment-banner {
                font-size: 12px;
                padding: 10px 14px;
        }
}

/* Very small screens */
@media (max-width: 360px) {
        .sa-header-logo {
                height: 34px;
        }

        .sa-header-title {
                font-size: 13px;
        }

        .sa-stat-value {
                font-size: 18px;
        }

        .sa-card {
                padding: 14px 10px;
        }
}

/* ---------- Legacy app compat (no wrapper) ---------- */
.sa-app:not(.sa-app-wrapper .sa-app) {
        max-width: 100%;
}