/**
 * Attendance Sync Engine - Frontend Styles
 *
 * @package AttendanceSyncEngine
 */

/* =========================================================================
   Variables
   ========================================================================= */
:root {
    --ase-present:   #22c55e;
    --ase-absent:    #ef4444;
    --ase-late:      #f59e0b;
    --ase-halfday:   #8b5cf6;
    --ase-leave:     #3b82f6;
    --ase-holiday:   #ec4899;
    --ase-weekoff:   #6b7280;
    --ase-bg:        #f9fafb;
    --ase-card-bg:   #ffffff;
    --ase-border:    #e5e7eb;
    --ase-text:      #111827;
    --ase-muted:     #6b7280;
    --ase-radius:    8px;
    --ase-shadow:    0 1px 3px rgba(0,0,0,0.08);
}

/* =========================================================================
   Wrapper
   ========================================================================= */
.ase-attendance-wrap,
.ase-dashboard-wrap,
.ase-leave-form-wrap {
    font-family: inherit;
    color: var(--ase-text);
    max-width: 100%;
}

/* =========================================================================
   Calendar Navigation
   ========================================================================= */
.ase-cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 16px;
    gap: 12px;
}

.ase-cal-label {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--ase-text);
}

.ase-nav-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    background: var(--ase-card-bg);
    border: 1px solid var(--ase-border);
    border-radius: var(--ase-radius);
    color: var(--ase-text);
    text-decoration: none;
    font-size: 0.9em;
    transition: background 0.2s;
}

.ase-nav-btn:hover {
    background: #f3f4f6;
    color: var(--ase-text);
    text-decoration: none;
}

/* =========================================================================
   Stat Cards Row
   ========================================================================= */
.ase-stat-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    margin: 0 0 20px;
}

.ase-stat-card {
    background: var(--ase-card-bg);
    border: 1px solid var(--ase-border);
    border-radius: var(--ase-radius);
    padding: 14px 10px;
    text-align: center;
    box-shadow: var(--ase-shadow);
}

.ase-stat-icon {
    font-size: 1.4em;
    margin-bottom: 4px;
}

.ase-stat-val {
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.ase-stat-lbl {
    font-size: 0.72em;
    color: var(--ase-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ase-stat-sub {
    font-size: 0.6em;
    font-weight: 500;
    color: var(--ase-muted);
}

/* =========================================================================
   Attendance Table
   ========================================================================= */
.ase-table-responsive {
    overflow-x: auto;
    border-radius: var(--ase-radius);
    box-shadow: var(--ase-shadow);
    margin-bottom: 20px;
}

/* Sticky header for long attendance tables (e.g. yearly view). */
.ase-table-responsive.ase-sticky-table-wrap {
    max-height: 600px;
    overflow-y: auto;
}

.ase-table.ase-sticky-header thead th {
    position: sticky;
    top: 0;
    z-index: 10;
}

.ase-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--ase-card-bg);
    font-size: 0.9em;
}

.ase-table thead th {
    background: #f3f4f6;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ase-muted);
    border-bottom: 2px solid var(--ase-border);
    white-space: nowrap;
}

.ase-table tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--ase-border);
    vertical-align: middle;
    white-space: nowrap;
}

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

.ase-row-today td {
    background: #fffbeb !important;
    font-weight: 600;
}

.ase-empty {
    color: var(--ase-muted);
}

/* =========================================================================
   Status Badges
   ========================================================================= */
.ase-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.78em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ase-badge-present  { background: #dcfce7; color: #15803d; }
.ase-badge-absent   { background: #fee2e2; color: #b91c1c; }
.ase-badge-late     { background: #fef3c7; color: #b45309; }
.ase-badge-half-day { background: #ede9fe; color: #6d28d9; }
.ase-badge-leave    { background: #dbeafe; color: #1d4ed8; }
.ase-badge-holiday  { background: #fce7f3; color: #be185d; }
.ase-badge-week-off { background: #f3f4f6; color: #374151; }
.ase-badge-none     { background: #f3f4f6; color: var(--ase-muted); }
.ase-badge-recurring{ background: #d1fae5; color: #065f46; }

/* Row coloring by status */
.ase-row-absent   td { background: #fff5f5; }
.ase-row-holiday  td { background: #fdf4ff; }
.ase-row-week-off td { background: #f9fafb; color: var(--ase-muted); }
.ase-row-leave    td { background: #eff6ff; }

/* =========================================================================
   Month Summary Bar
   ========================================================================= */
.ase-month-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--ase-card-bg);
    border: 1px solid var(--ase-border);
    border-radius: var(--ase-radius);
    padding: 16px;
    box-shadow: var(--ase-shadow);
}

.ase-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    padding: 6px 10px;
    background: var(--ase-bg);
    border-radius: 6px;
}

.ase-summary-label {
    font-size: 0.7em;
    color: var(--ase-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.ase-summary-val {
    font-size: 1.1em;
    font-weight: 700;
}

.ase-color-present  { color: var(--ase-present); }
.ase-color-absent   { color: var(--ase-absent); }
.ase-color-late     { color: var(--ase-late); }
.ase-color-halfday  { color: var(--ase-halfday); }
.ase-color-leave    { color: var(--ase-leave); }
.ase-color-holiday  { color: var(--ase-holiday); }

/* =========================================================================
   Dashboard Header
   ========================================================================= */
.ase-dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.ase-emp-greeting {
    font-size: 1.3em;
    font-weight: 700;
    margin: 0;
    color: var(--ase-text);
}

.ase-admin-emp-selector select,
.ase-emp-select {
    padding: 8px 12px;
    border: 1px solid var(--ase-border);
    border-radius: var(--ase-radius);
    font-size: 0.9em;
    background: var(--ase-card-bg);
    cursor: pointer;
    min-width: 200px;
}

/* =========================================================================
   Leave Form
   ========================================================================= */
.ase-leave-form-wrap {
    background: var(--ase-card-bg);
    border: 1px solid var(--ase-border);
    border-radius: var(--ase-radius);
    padding: 24px;
    box-shadow: var(--ase-shadow);
    max-width: 480px;
}

.ase-leave-form-wrap h3 {
    margin: 0 0 20px;
    font-size: 1.1em;
    font-weight: 600;
}

.ase-form-group {
    margin-bottom: 16px;
}

.ase-form-group label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ase-text);
}

.ase-required {
    color: var(--ase-absent);
}

.ase-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--ase-border);
    border-radius: var(--ase-radius);
    font-size: 0.9em;
    background: var(--ase-card-bg);
    color: var(--ase-text);
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.ase-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.ase-textarea {
    resize: vertical;
    min-height: 80px;
}

.ase-btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: var(--ase-radius);
    font-size: 0.9em;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.ase-btn:hover {
    opacity: 0.88;
}

.ase-btn-primary {
    background: #2563eb;
    color: #fff;
}

.ase-form-message {
    padding: 10px 14px;
    border-radius: var(--ase-radius);
    margin-bottom: 14px;
    font-size: 0.9em;
    font-weight: 500;
}

.ase-form-message.ase-success {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.ase-form-message.ase-error {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

/* =========================================================================
   Notices
   ========================================================================= */
.ase-login-notice,
.ase-notice {
    padding: 14px 18px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--ase-radius);
    color: #1e40af;
    font-size: 0.9em;
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 600px) {
    .ase-stat-cards-row {
        grid-template-columns: repeat(3, 1fr);
    }

    .ase-cal-nav {
        flex-wrap: wrap;
    }

    .ase-dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .ase-month-summary {
        gap: 8px;
    }

    .ase-summary-item {
        min-width: 70px;
    }
}

@media (max-width: 400px) {
    .ase-stat-cards-row {
        grid-template-columns: repeat(2, 1fr);
    }
}