/* ===================================================
   VARIABLES & RESET
   =================================================== */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --secondary: #6366f1;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #06b6d4;
    --info-light: #cffafe;
    --dark: #1e293b;
    --dark-light: #334155;
    --gray: #64748b;
    --gray-light: #94a3b8;
    --light: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: all 0.3s ease;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f1f5f9;
    color: var(--dark);
    line-height: 1.6;
    overflow-x: hidden;
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; }

/* ===================================================
   APP LAYOUT
   =================================================== */
.app-wrapper { display: flex; min-height: 100vh; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: var(--transition);
}

.content-area {
    padding: 24px;
    margin-top: var(--topbar-height);
    flex: 1;
}

/* ===================================================
   SIDEBAR
   =================================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--dark);
    color: #cbd5e1;
    z-index: 1000;
    overflow-y: auto;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
    border: 2px solid rgba(255,255,255,0.2);
}

.sidebar-logo-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-size: 1.5rem;
    color: white;
}

.sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    line-height: 1.3;
}

.sidebar-nav { padding: 10px 0; }

.nav-list { list-style: none; }

.nav-section {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #64748b;
    padding: 20px 20px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: #94a3b8;
    font-size: 0.9rem;
    font-weight: 400;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-link.active {
    background: rgba(37, 99, 235, 0.15);
    color: white;
    border-left-color: var(--primary);
    font-weight: 500;
}

.nav-link i {
    width: 20px;
    margin-right: 12px;
    font-size: 1rem;
    text-align: center;
}

.nav-link span { white-space: nowrap; }

/* ===================================================
   TOPBAR
   =================================================== */
.topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 999;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

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

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--gray);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: var(--transition);
    display: none;
}

.sidebar-toggle:hover { background: var(--light); color: var(--dark); }

.page-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--dark);
}

.topbar-right { display: flex; align-items: center; gap: 20px; }

.topbar-date {
    color: var(--gray);
    font-size: 0.85rem;
}

.topbar-date i { margin-right: 6px; }

/* User Dropdown */
.dropdown { position: relative; }

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius);
    transition: var(--transition);
}

.dropdown-toggle:hover { background: var(--light); }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.user-name { font-weight: 500; color: var(--dark); font-size: 0.9rem; }

.dropdown-toggle .fa-chevron-down { font-size: 0.7rem; color: var(--gray); }

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    display: none;
    z-index: 1001;
    overflow: hidden;
}

.dropdown-menu.show { display: block; }

.dropdown-header {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
}

.dropdown-header strong { font-size: 0.9rem; color: var(--dark); }
.dropdown-header small { color: var(--gray); text-transform: capitalize; }

.dropdown-divider { border-top: 1px solid var(--border); }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--dark);
    font-size: 0.9rem;
    transition: var(--transition);
}

.dropdown-item:hover { background: var(--light); }
.dropdown-item.text-danger { color: var(--danger); }

/* ===================================================
   CARDS
   =================================================== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h2, .card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--dark);
    margin: 0;
}

.card-body { padding: 20px; }

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--light);
}

/* ===================================================
   STATS CARDS (Dashboard)
   =================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: #ede9fe; color: var(--secondary); }
.stat-icon.cyan { background: var(--info-light); color: var(--info); }

.stat-info h4 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-info p {
    font-size: 0.85rem;
    color: var(--gray);
    margin: 0;
}

/* ===================================================
   TABLES
   =================================================== */
.table-responsive { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th {
    background: var(--light);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:hover { background: #f8fafc; }

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

.table .actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px;
    font-family: 'Inter', sans-serif;
    outline: none;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 8px;
    font-family: 'Inter', sans-serif;
}

.dataTables_wrapper .dataTables_info { font-size: 0.85rem; color: var(--gray); padding-top: 12px; }

.dataTables_wrapper .dataTables_paginate { padding-top: 12px; }

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 6px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border) !important;
    background: white !important;
    color: var(--dark) !important;
    margin: 0 2px;
    font-size: 0.85rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

/* ===================================================
   FORMS
   =================================================== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--dark);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--dark);
    background: white;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder { color: var(--gray-light); }

select.form-control { cursor: pointer; }

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.form-text {
    font-size: 0.8rem;
    color: var(--gray);
    margin-top: 4px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ===================================================
   BUTTONS
   =================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; color: white; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; color: white; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; color: white; }

.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #0891b2; color: white; }

.btn-secondary { background: var(--gray); color: white; }
.btn-secondary:hover { background: var(--dark-light); color: white; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--dark);
}
.btn-outline:hover { background: var(--light); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.btn-lg { padding: 12px 28px; font-size: 1rem; }

.btn-block { width: 100%; justify-content: center; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===================================================
   BADGES
   =================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-secondary { background: #e2e8f0; color: var(--gray); }

/* ===================================================
   ALERTS
   =================================================== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}

.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: var(--info-light); color: #155e75; border: 1px solid #67e8f9; }

.alert-dismissible { position: relative; padding-right: 40px; }

.alert-close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    opacity: 0.6;
    line-height: 1;
}

.alert-close:hover { opacity: 1; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===================================================
   PAGINATION
   =================================================== */
.pagination {
    display: flex;
    list-style: none;
    gap: 4px;
    justify-content: center;
    margin-top: 20px;
}

.page-item { }

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--dark);
    font-size: 0.85rem;
    transition: var(--transition);
}

.page-link:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.page-item.active .page-link { background: var(--primary); color: white; border-color: var(--primary); }

/* ===================================================
   MODAL
   =================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.show { display: flex; }

.modal {
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 1.1rem; margin: 0; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
    line-height: 1;
}

.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ===================================================
   WORKFLOW TIMELINE
   =================================================== */
.workflow-timeline {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 20px 0;
    flex-wrap: wrap;
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--light);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray);
    position: relative;
}

.workflow-step.completed {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

.workflow-step.current {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.workflow-step.rejected {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

.workflow-connector {
    width: 30px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
}

.workflow-connector.completed { background: var(--success); }

/* ===================================================
   LOGIN PAGE
   =================================================== */
.login-page {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container { width: 100%; max-width: 420px; }

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    animation: scaleIn 0.4s ease;
}

.login-header { text-align: center; margin-bottom: 30px; }

.login-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
}

.login-logo-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 2rem;
    color: white;
}

.login-header h1 {
    font-size: 1.3rem;
    color: var(--dark);
    margin-bottom: 4px;
}

.login-header p { color: var(--gray); font-size: 0.9rem; }

.login-form .form-group label {
    font-size: 0.85rem;
}

.login-form .form-group label i { margin-right: 4px; color: var(--gray); }

.password-wrapper { position: relative; }

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray);
    cursor: pointer;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.login-footer p { font-size: 0.8rem; color: var(--gray); }

/* ===================================================
   PROGRESS BAR
   =================================================== */
.progress {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* ===================================================
   LOADING SPINNER
   =================================================== */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm { width: 20px; height: 20px; border-width: 2px; }

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.loading-overlay.show { display: flex; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================================
   EMPTY STATE
   =================================================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
}

.empty-state i { font-size: 3rem; margin-bottom: 16px; color: var(--border); }
.empty-state h4 { color: var(--dark); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; }

/* ===================================================
   UTILITIES
   =================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-bold { font-weight: 600; }
.text-sm { font-size: 0.85rem; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.w-100 { width: 100%; }

.signature-preview {
    max-width: 120px;
    max-height: 60px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
}

/* ===================================================
   FILTER BAR
   =================================================== */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-bar .form-control {
    max-width: 200px;
}

/* ===================================================
   PRINT STYLES
   =================================================== */
@media print {
    .sidebar, .topbar, .main-footer, .btn, .alert { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-area { margin-top: 0 !important; padding: 0 !important; }
    .card { box-shadow: none !important; border: none !important; }
}

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 1024px) {
    .sidebar-toggle { display: block; }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open { transform: translateX(0); }

    .main-content { margin-left: 0; }

    .topbar { left: 0; }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.show { display: block; }
}

@media (max-width: 768px) {
    .content-area { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .card-header { flex-direction: column; align-items: flex-start; }
    .topbar-date { display: none; }
    .filter-bar .form-control { max-width: 100%; flex: 1; }
    .workflow-timeline { flex-direction: column; align-items: flex-start; }
    .workflow-connector { width: 2px; height: 20px; margin-left: 20px; }
}
