/* ISPAC Certification Manager - Styles */
:root {
    --primary: #1a2a3a;
    --primary-light: #243b50;
    --primary-dark: #0f1a24;
    --accent: #e8850c;
    --accent-hover: #d17a0a;
    --blue: #3b82f6;
    --blue-light: #60a5fa;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --sidebar-width: 260px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --bg-success: #f0fdf4;
    --bg-danger: #fef2f2;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--gray-100); color: var(--gray-800); font-size: 14px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-width);
    background: var(--primary); color: var(--white);
    display: flex; flex-direction: column; z-index: 100; overflow-y: auto;
}
.sidebar-logo {
    padding: 24px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo h2 { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.sidebar-logo h2 span { color: var(--accent); }
.sidebar-logo p { font-size: 11px; color: var(--gray-400); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 20px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-400); margin-top: 8px; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 20px;
    cursor: pointer; transition: background 0.15s; color: var(--gray-300); font-size: 13px;
}
.nav-item:hover { background: var(--primary-light); color: var(--white); }
.nav-item.active { background: var(--primary-light); color: var(--white); border-left: 3px solid var(--accent); padding-left: 17px; }
.nav-item .nav-icon { width: 18px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: space-between;
}
.user-info { font-size: 12px; }
.user-info .user-name { font-weight: 600; color: var(--white); }
.user-info .user-role { color: var(--gray-400); font-size: 11px; }
#btn-logout {
    background: none; border: 1px solid rgba(255,255,255,0.2); color: var(--gray-400);
    padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px;
}
#btn-logout:hover { background: rgba(255,255,255,0.1); color: var(--white); }

/* ========== MAIN CONTENT ========== */
#main-content {
    margin-left: var(--sidebar-width); padding: 24px 32px; min-height: 100vh;
    transition: margin-left 0.2s;
}

.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 24px; font-weight: 700; color: var(--gray-800); }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ========== CARDS ========== */
.card {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
    display: flex; justify-content: space-between; align-items: center;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ========== STATS ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--white); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); border-left: 4px solid var(--blue);
}
.stat-card.stat-danger { border-left-color: var(--red); }
.stat-card.stat-warning { border-left-color: var(--yellow); }
.stat-card.stat-attention { border-left-color: var(--accent); }
.stat-number { font-size: 32px; font-weight: 700; color: var(--gray-800); }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ========== GRID ========== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
    #main-content { margin-left: 0 !important; padding: 16px; }
    .sidebar { display: none; }
}

/* ========== TABLE ========== */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--gray-500); border-bottom: 2px solid var(--gray-200);
    background: var(--gray-50);
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); }
.table-compact td { padding: 6px 10px; font-size: 13px; }
.table tbody tr:hover { background: var(--gray-50); }
.table .clickable { cursor: pointer; }

/* ========== BADGES ========== */
.badge {
    display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 600; letter-spacing: 0.3px; white-space: nowrap;
}
.level-1 { background: #f5f5f5; color: #666; border: 1px solid #ccc; }
.level-2 { background: #dcfce7; color: #166534; }
.level-3 { background: #fee2e2; color: #991b1b; }
.badge-expired { background: #fee2e2; color: #991b1b; }
.badge-critical { background: #fef3c7; color: #92400e; animation: pulse 2s infinite; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-attention { background: #fff7ed; color: #9a3412; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-muted { background: var(--gray-100); color: var(--gray-500); }
.badge-info { background: #dbeafe; color: #1e40af; }

.level-1-bg { background: var(--gray-300); }
.level-2-bg { background: var(--green); }
.level-3-bg { background: var(--red); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

/* ========== FORMS ========== */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.input {
    padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: 6px;
    font-size: 14px; background: var(--white); color: var(--gray-800);
    transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.input-sm { padding: 6px 10px; font-size: 13px; }
select.input { cursor: pointer; }
textarea.input { resize: vertical; font-family: inherit; }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
    border: none; border-radius: 6px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== FILTERS ========== */
.filters-bar {
    display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center;
    padding: 16px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
}
.filters-bar .input { flex: 1; min-width: 150px; }
.filters-bar .input-sm { flex: 0; min-width: 130px; }

/* ========== DETAIL GRID ========== */
.detail-grid { display: flex; flex-direction: column; gap: 8px; }
.detail-row {
    display: flex; justify-content: space-between; padding: 6px 0;
    border-bottom: 1px solid var(--gray-100);
}
.detail-row span { color: var(--gray-500); font-size: 13px; }
.detail-row strong { font-size: 13px; text-align: right; }

/* ========== DOCUMENT ROW ========== */
.doc-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

/* ========== LEVEL BARS ========== */
.level-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.level-bar-label { width: 100px; }
.level-bar-track { flex: 1; height: 24px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.level-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.level-bar-count { font-weight: 700; width: 30px; text-align: right; }

/* ========== REGION LIST ========== */
.region-row {
    display: flex; justify-content: space-between; padding: 6px 0;
    border-bottom: 1px solid var(--gray-100);
}

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

/* ========== LOGIN ========== */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--primary);
}
.login-card {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    width: 380px; max-width: 90vw; overflow: hidden;
}
.login-header {
    background: var(--primary-dark); padding: 30px; text-align: center;
}
.login-header h1 { color: var(--white); font-size: 28px; letter-spacing: 2px; }
.login-header .text-accent { color: var(--accent); }
.login-header p { color: var(--gray-400); font-size: 12px; margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }
.login-card form { padding: 30px; }
.login-card .form-group { margin-bottom: 16px; }
.login-card .btn { margin-top: 8px; padding: 12px; font-size: 15px; }

/* ========== TOAST ========== */
.toast {
    position: fixed; bottom: 24px; right: 24px; padding: 12px 24px;
    border-radius: 8px; font-size: 14px; font-weight: 500; z-index: 9999;
    transform: translateY(100px); opacity: 0; transition: all 0.3s;
    box-shadow: var(--shadow-lg);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: #166534; color: var(--white); }
.toast-error { background: #991b1b; color: var(--white); }
.toast-info { background: #1e40af; color: var(--white); }

/* ========== UTILITIES ========== */
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 12px; }
.text-error { color: var(--red); font-size: 13px; margin-top: 8px; }
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.page-loader { padding: 40px; text-align: center; color: var(--gray-400); }

.clickable { cursor: pointer; }
.clickable:hover { background: var(--gray-50); }

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px; animation: fadeIn 0.2s;
}
.modal {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    width: 700px; max-width: 95vw; max-height: 90vh; overflow: hidden;
    display: flex; flex-direction: column; animation: slideUp 0.2s;
}
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ========== REFERENCE LIST TABLE ========== */
#ref-table .input-sm { padding: 4px 6px; font-size: 12px; }
#ref-table td { vertical-align: top; padding: 4px; }
#ref-table textarea { resize: vertical; min-height: 40px; }
