/* ============================================
   Attendance System - Complete Stylesheet
   ============================================ */

/* ---------- Reset & Base ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin: 0;
}

/* ---------- Container ---------- */
.container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.container-wide {
    max-width: 900px;
}

/* ---------- Card ---------- */
.card {
    background: #ffffff;
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    animation: slideUp 0.4s ease;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

/* ---------- Logo Area ---------- */
.logo-area {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 12px;
    border-radius: 16px;
}

.logo-area h1 {
    font-size: 24px;
    color: #333;
    font-weight: 700;
    margin: 0;
}

/* ---------- Form ---------- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    outline: none;
    background: #fafafa;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #667eea;
    background: #fff;
}

.form-group input::placeholder {
    color: #bbb;
}

.form-group .hint {
    display: block;
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* ---------- Buttons ---------- */
.btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-outline {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-outline:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.btn-small {
    width: auto;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 8px;
}

.btn-danger {
    background: #ff6b6b;
    color: white;
}

.btn-danger:hover {
    background: #ee5a24;
}

/* ---------- Header Bar ---------- */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.header-bar h2 {
    font-size: 20px;
    color: #333;
    margin: 0;
}

.datetime {
    font-size: 13px;
    color: #888;
    margin-top: 4px;
}

/* ---------- Error / Success Messages ---------- */
.error {
    background: #fff0f0;
    color: #d32f2f;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-top: 16px;
    border: 1px solid #ffcdd2;
}

.success {
    background: #f0fff0;
    color: #2e7d32;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-top: 16px;
    border: 1px solid #c8e6c9;
}

.hidden {
    display: none !important;
}

/* ---------- Loading Spinner ---------- */
#loadingSpinner {
    text-align: center;
    padding: 20px;
    margin-top: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ---------- Footer Text ---------- */
.footer-text {
    text-align: center;
    margin-top: 24px;
    color: #aaa;
}

.footer-text a {
    color: #667eea;
    text-decoration: none;
}

/* ---------- Check-In / Check-Out Cards ---------- */
.attendance-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.action-card {
    padding: 20px;
    text-align: center;
    border-radius: 14px;
    border: 2px solid #e8e8ff;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.action-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.action-card.selected {
    border-color: #667eea;
    background: #f0f0ff;
}

.action-card .icon {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

.action-card .label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.action-card .time {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

/* ---------- Attendance Status ---------- */
.status-bar {
    text-align: center;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 14px;
}

.status-bar.checked-in {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.status-bar.checked-out {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #e0e0e0;
}

.status-bar .status-time {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 4px;
}

/* ---------- Site Select ---------- */
.site-select-group {
    margin-bottom: 20px;
}

.site-select-group select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    background: #fafafa;
    outline: none;
    cursor: pointer;
}

.site-select-group select:focus {
    border-color: #667eea;
}

/* ---------- Notes Textarea ---------- */
.notes-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    resize: vertical;
    min-height: 80px;
    outline: none;
    background: #fafafa;
    font-family: inherit;
}

.notes-group textarea:focus {
    border-color: #667eea;
    background: #fff;
}

/* ---------- User Profile Info ---------- */
.profile-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9ff;
    border-radius: 12px;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
}

.profile-details .profile-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.profile-details .profile-info-text {
    font-size: 12px;
    color: #888;
}

/* ---------- Today's Status Badge ---------- */
.today-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.today-status.present {
    background: #e8f5e9;
    color: #2e7d32;
}

.today-status.absent {
    background: #ffebee;
    color: #c62828;
}

.today-status.late {
    background: #fff3e0;
    color: #e65100;
}

/* ============================================ */
/* DASHBOARD & MANAGER STYLES                   */
/* ============================================ */

/* Dashboard Stats Grid */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: #f8f9ff;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 1px solid #e8e8ff;
}

.stat-card-lg {
    padding: 20px 12px;
}

.stat-number {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: #333;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.stat-green .stat-number { color: #4CAF50; }
.stat-orange .stat-number { color: #ff9800; }
.stat-red .stat-number { color: #ff6b6b; }

/* Month Selector */
.month-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.month-selector h3 {
    font-size: 18px;
    color: #333;
}

.month-selector .btn {
    width: auto;
    padding: 6px 12px;
}

/* Calendar Grid */
.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}

.cal-day-name {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    padding: 8px 0;
}

.calendar-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 12px;
    background: #f9f9f9;
    cursor: default;
    min-height: 50px;
    padding: 4px;
}

.cal-cell.cal-empty {
    background: transparent;
}

.cal-day-num {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.cal-status {
    font-size: 10px;
    font-weight: 700;
    margin-top: 2px;
}

.cal-present {
    background: #e8f5e9;
}
.cal-present .cal-status { color: #2e7d32; }

.cal-late {
    background: #fff3e0;
}
.cal-late .cal-status { color: #e65100; }

.cal-absent {
    background: #ffebee;
}
.cal-absent .cal-status { color: #c62828; }

.cal-leave {
    background: #e3f2fd;
}
.cal-leave .cal-status { color: #1565c0; }

.cal-weekend {
    background: #f5f5f5;
}
.cal-weekend .cal-status { color: #9e9e9e; }

.cal-today {
    border: 2px solid #667eea;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #666;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-green { background: #4CAF50; }
.dot-red { background: #ff6b6b; }
.dot-orange { background: #ff9800; }
.dot-blue { background: #2196F3; }
.dot-gray { background: #9e9e9e; }

/* Manager Table */
.manager-table-section {
    margin-bottom: 24px;
}

.manager-table-section h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 12px;
}

.table-responsive {
    overflow-x: auto;
}

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

.manager-table th {
    background: #f8f9ff;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e8e8ff;
}

.manager-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    color: #444;
}

.manager-table tr:hover td {
    background: #fafafa;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-present {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-late {
    background: #fff3e0;
    color: #e65100;
}

.status-absent {
    background: #ffebee;
    color: #c62828;
}

/* Manager Actions */
.manager-actions {
    margin-top: 16px;
}

.manager-actions h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 12px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.action-buttons .btn {
    width: auto;
    flex: 1;
    min-width: 150px;
}

/* Export Section */
.export-section {
    margin-top: 20px;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 8px;
}

/* ---------- Link buttons ---------- */
.link-btn {
    background: none;
    border: none;
    color: #667eea;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px;
}

.link-btn:hover {
    color: #764ba2;
}

/* ---------- Focus outline ---------- */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* ============================================ */
/* NEW: LEAVE MANAGEMENT PAGE                   */
/* ============================================ */

/* Balance Container */
.balance-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.balance-container .card {
    padding: 24px 16px;
    text-align: center;
    border-radius: 14px;
    background: #f8f9ff;
    border: 1px solid #e8e8ff;
    box-shadow: none;
    animation: none;
}

.balance-container .card h3 {
    font-size: 14px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.balance-count {
    font-size: 32px;
    font-weight: 700;
    color: #333;
}

/* Form Container (for leave form) */
.form-container {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
    border: 1px solid #f0f0f0;
}

.form-container h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 20px;
    font-weight: 600;
}

.form-container label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    margin-top: 16px;
}

.form-container label:first-of-type {
    margin-top: 0;
}

.form-container input,
.form-container select,
.form-container textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    background: #fafafa;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.form-container input:focus,
.form-container select:focus,
.form-container textarea:focus {
    border-color: #667eea;
    background: #fff;
}

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

.form-container .btn-primary {
    margin-top: 20px;
}

/* Leave History */
.history-container {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    border: 1px solid #f0f0f0;
}

.history-container h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 16px;
    font-weight: 600;
}

.history-container table {
    width: 100%;
    border-collapse: collapse;
}

.history-container th {
    text-align: left;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    border-bottom: 2px solid #e8e8ff;
}

.history-container td {
    padding: 10px 8px;
    font-size: 14px;
    color: #444;
    border-bottom: 1px solid #f0f0f0;
}

/* Leave Status Badges */
.status-approved {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-pending {
    background: #fff8e1;
    color: #f57f17;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-rejected {
    background: #ffebee;
    color: #c62828;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

/* ============================================ */
/* NEW: HOLIDAYS PAGE                           */
/* ============================================ */

.holiday-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.holiday-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #ffffff;
    border-radius: 14px;
    padding: 16px 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid #f0f0f0;
    transition: transform 0.2s ease;
}

.holiday-card:hover {
    transform: translateX(4px);
}

.date-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
    color: white;
}

.date-box .day {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}

.date-box .month {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.holiday-info h4 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.holiday-info p {
    font-size: 13px;
    color: #888;
}

/* ============================================ */
/* NEW: PROFILE PAGE                            */
/* ============================================ */

.profile-main {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.profile-header {
    text-align: center;
    margin-bottom: 24px;
}

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 32px;
    margin: 0 auto 12px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.profile-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #333;
}

.profile-header p {
    font-size: 14px;
    color: #888;
    margin-top: 4px;
}

/* Info List */
.info-list {
    background: #ffffff;
    border-radius: 16px;
    padding: 8px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    border: 1px solid #f0f0f0;
    margin-bottom: 24px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #f5f5f5;
}

.info-item:last-child {
    border-bottom: none;
}

.info-item label {
    font-size: 14px;
    font-weight: 500;
    color: #888;
}

.info-item p {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

/* Logout Button */
.btn-logout {
    width: 100%;
    padding: 14px 24px;
    border: 2px solid #ff6b6b;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    background: transparent;
    color: #ff6b6b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-logout:hover {
    background: #ff6b6b;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.3);
}

/* ============================================ */
/* NEW: INNER PAGE LAYOUT                       */
/* ============================================ */

/* Override body for inner pages (remove gradient, use white bg) */
body.page-inner {
    display: block;
    background: #f5f6fa;
    padding: 0;
    min-height: 100vh;
}

.page-inner main {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* Navigation Bar for inner pages */
.page-nav {
    background: #ffffff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-nav a {
    text-decoration: none;
    color: #667eea;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.page-nav a:hover {
    background: #f0f0ff;
}

.page-nav h2 {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin: 0;
    flex: 1;
    text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .container {
        max-width: 100%;
    }
    
    .card {
        padding: 28px 20px;
        border-radius: 16px;
    }

    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .manager-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
    
    .cal-cell {
        min-height: 40px;
        font-size: 11px;
    }

    .attendance-actions {
        grid-template-columns: 1fr;
    }

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

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1;
    }

    .profile-info {
        flex-wrap: wrap;
    }

    /* Responsive for new pages */
    .balance-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .balance-container .card {
        padding: 16px 12px;
    }

    .balance-count {
        font-size: 26px;
    }

    .holiday-card {
        padding: 12px 16px;
    }

    .date-box {
        min-width: 48px;
        padding: 6px 10px;
    }

    .date-box .day {
        font-size: 18px;
    }

    .info-item {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .page-nav {
        padding: 10px 12px;
    }

    .page-nav h2 {
        font-size: 16px;
    }
}

/* ---------- Animation ---------- */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Scrollbar Styling ---------- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}
