/* Reset and Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: all 0.2s ease;
}

:root {
    --primary: #0284c7;
    /* Sky blue primary */
    --primary-hover: #0369a1;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-app: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --border-color: rgba(226, 232, 240, 0.8);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Readex Pro', 'Inter', sans-serif;
    background-color: var(--bg-app);
    background-image: radial-gradient(at 0% 0%, rgba(2, 132, 199, 0.05) 0px, transparent 50%),
        radial-gradient(at 50% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    direction: rtl;
    line-height: 1.6;
}

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem 2rem;
    box-shadow: var(--shadow);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.logo-icon svg {
    width: 26px;
    height: 26px;
}

.logo-text h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
}

.logo-text p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.3);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-2px);
}

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

.btn .icon {
    width: 18px;
    height: 18px;
}

/* Grid Layout */
.main-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* Sidebar and Cards */
.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-main);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* Dropzone */
.dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    background: rgba(248, 250, 252, 0.5);
    transition: all 0.25s ease;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: rgba(2, 132, 199, 0.05);
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 1rem;
}

.upload-icon svg {
    width: 42px;
    height: 42px;
}

.dropzone-main-text {
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.dropzone-sub-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.file-format-badge {
    background: #e0f2fe;
    color: var(--primary);
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-weight: 500;
}

/* File Info Box */
.file-info-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-top: 1rem;
}

.file-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-icon {
    font-size: 1.5rem;
}

.file-meta {
    display: flex;
    flex-direction: column;
}

.file-name {
    font-size: 0.85rem;
    font-weight: 500;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
}

.btn-remove:hover {
    color: var(--danger);
}

/* Shift Settings */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    cursor: pointer;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

.sub-checkbox {
    margin-top: 0.75rem;
    padding-right: 1.5rem;
    border-right: 2px solid var(--border-color);
}

.label-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.4rem;
}

.days-select {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.days-select label {
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.w-full {
    width: 100%;
}

.mt-4 {
    margin-top: 1rem;
}

/* Main Dashboard & Content */
.content-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stats-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.stats-card.glass {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
}

.stats-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-icon svg {
    width: 24px;
    height: 24px;
}

.text-primary {
    background: #e0f2fe;
    color: var(--primary);
}

.text-success {
    background: #d1fae5;
    color: var(--success);
}

.text-warning {
    background: #fef3c7;
    color: var(--warning);
}

.text-danger {
    background: #fee2e2;
    color: var(--danger);
}

.stats-data {
    display: flex;
    flex-direction: column;
}

.stats-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stats-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Filters Card */
.filter-card {
    padding: 1.25rem 1.5rem;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.filter-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--primary-hover);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .filter-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .filter-grid {
        grid-template-columns: 1fr;
    }
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.filter-item label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.input-with-icon {
    position: relative;
}

.input-icon {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-with-icon .form-input {
    padding-right: 2rem;
}

.search-box {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .search-box {
        grid-column: span 2;
    }
}

/* Report Table */
.table-card {
    padding: 1.5rem;
}

.table-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.table-header h2 {
    font-size: 1.15rem;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.badge {
    background: #f1f5f9;
    color: var(--text-main);
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: white;
}

.attendance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: right;
}

.attendance-table th {
    background: #f8fafc;
    color: var(--text-main);
    font-weight: 600;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.attendance-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
}

.attendance-table tbody tr:hover {
    background: rgba(2, 132, 199, 0.02);
}

.attendance-table tr.table-placeholder td {
    padding: 4rem 1rem;
    text-align: center;
}

.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.placeholder-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.placeholder-content p {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 380px;
}

.table-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.actions-col {
    width: 90px;
    text-align: center;
}

/* Status Badges */
.status-present {
    background: #d1fae5;
    color: #065f46;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.status-late {
    background: #fef3c7;
    color: #92400e;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.status-incomplete {
    background: #ffedd5;
    color: #9a3412;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.status-no_checkout {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.status-no_checkin {
    background: #f3e8ff;
    color: #6b21a8;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: white;
    width: 100%;
    max-width: 650px;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal-card {
    transform: scale(1);
}

.modal-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.modal-header p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
}

.btn-close-modal:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.summary-details-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.summary-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.summary-value {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.modal-body h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.punches-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: right;
}

.punches-table th {
    background: #f1f5f9;
    padding: 0.6rem 0.8rem;
    font-weight: 600;
}

.punches-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #f1f5f9;
}

.punch-in {
    color: var(--success);
    font-weight: 600;
}

.punch-out {
    color: var(--danger);
    font-weight: 600;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    background: #f8fafc;
}

/* ── Step Modals (Column Mapper & Deleter) ─────────── */
.step-modal-box {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 18px;
    width: 100%;
    max-width: 660px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    font-family: 'Readex Pro', sans-serif;
}
.step-modal-header { padding: 1.5rem 1.75rem 1.1rem; border-bottom: 1px solid #1e293b; }
.step-badge {
    display: inline-block; background: #1e3a5f; color: #7dd3fc;
    font-size: 0.72rem; font-weight: 600; padding: 0.2rem 0.7rem;
    border-radius: 20px; margin-bottom: 0.6rem;
}
.step-modal-header h2 { color: #f1f5f9; font-size: 1.15rem; font-weight: 700; margin: 0 0 0.35rem; }
.step-modal-header p  { color: #64748b; font-size: 0.82rem; margin: 0; }
.step-modal-body   { padding: 1.25rem 1.75rem; }
.step-modal-footer { padding: 1.1rem 1.75rem; border-top: 1px solid #1e293b; display: flex; gap: 0.75rem; align-items: center; }

.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 560px) { .fields-grid { grid-template-columns: 1fr; } }

.field-item label { display: block; font-size: 0.78rem; font-weight: 500; margin-bottom: 0.3rem; }
.field-item select {
    width: 100%; background: #1e293b; color: #f1f5f9;
    border: 1px solid #334155; border-radius: 8px;
    padding: 0.45rem 0.65rem; font-size: 0.82rem;
    font-family: 'Readex Pro', sans-serif; cursor: pointer; outline: none;
}
.field-item select:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }

.info-box {
    background: #1e3a5f; border: 1px solid #1d4ed8; border-radius: 8px;
    padding: 0.7rem 1rem; margin-top: 1rem; font-size: 0.78rem; color: #93c5fd; line-height: 1.5;
}

.col-checkboxes {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem;
    max-height: 360px; overflow-y: auto; padding: 0.25rem 0;
}
@media (max-width: 480px) { .col-checkboxes { grid-template-columns: 1fr; } }

.col-checkbox-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.75rem; background: #1e293b; border: 1px solid #334155;
    border-radius: 8px; cursor: pointer; font-size: 0.8rem; color: #e2e8f0;
    transition: background 0.15s; user-select: none;
}
.col-checkbox-item:hover:not(.col-used) { background: #263548; border-color: #475569; }
.col-checkbox-item.col-used { border-color: #1d4ed8; background: #172554; cursor: default; }
.col-checkbox-item input[type="checkbox"] { accent-color: #3b82f6; width: 15px; height: 15px; flex-shrink: 0; }
.col-checkbox-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.col-tag {
    font-size: 0.65rem; background: #1d4ed8; color: #bfdbfe;
    padding: 0.1rem 0.4rem; border-radius: 10px; flex-shrink: 0; font-weight: 600;
}

.btn-modal-primary {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff; border: none; border-radius: 9px;
    padding: 0.65rem 1.4rem; font-size: 0.88rem;
    font-family: 'Readex Pro', sans-serif; font-weight: 600;
    cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}
.btn-modal-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(59,130,246,0.4); }

.btn-modal-secondary {
    background: #1e293b; color: #94a3b8; border: 1px solid #334155;
    border-radius: 9px; padding: 0.65rem 1.1rem; font-size: 0.88rem;
    font-family: 'Readex Pro', sans-serif; cursor: pointer; transition: all 0.2s;
}
.btn-modal-secondary:hover { background: #263548; color: #e2e8f0; border-color: #475569; }

/* ── Print Styles ────────────────────────────────────────────────────────── */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    aside.sidebar,
    .controls-bar,
    .filters-bar,
    .btn,
    .actions-col,
    .modal-overlay {
        display: none !important;
    }
    .content-section {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    /* Add a professional print header style */
    .print-title {
        display: block !important;
        text-align: center;
        background: #1e293b !important;
        color: white !important;
        padding: 1.5rem;
        margin-bottom: 2rem;
        border-radius: 8px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        font-family: 'Readex Pro', sans-serif;
    }
    .print-title h2 { margin: 0; font-size: 24px; font-weight: bold; }
    .print-title p { margin: 0.5rem 0 0 0; font-size: 14px; opacity: 0.9; }
    
    .table-responsive {
        box-shadow: none !important;
        border: 1px solid #e2e8f0 !important;
    }
    table th {
        background: #0ea5e9 !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    table th, table td {
        border: 1px solid #cbd5e1 !important;
    }
    td.punch-in { color: #059669 !important; font-weight: bold; }
    td.punch-out { color: #dc2626 !important; font-weight: bold; }
}

/* ── Login Overlay Styles ────────────────────────────────────────────────── */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-app);
    background-image: radial-gradient(at 0% 0%, rgba(2, 132, 199, 0.05) 0px, transparent 50%),
        radial-gradient(at 50% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-card h2 {
    font-size: 1.5rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    text-align: right;
}

.login-form .form-group label {
    font-weight: 500;
    color: var(--text-main);
    display: block;
    margin-bottom: 0.5rem;
}