/* ========================================
   SURAT PERSETUJUAN ONLINE - ADMIN STYLES
   Blue Primary + White Theme
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
    /* Primary Blue */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-lighter: #60a5fa;
    --primary-bg: rgba(37, 99, 235, 0.06);
    --primary-bg-hover: rgba(37, 99, 235, 0.1);

    --secondary: #1e40af;
    --accent: #0ea5e9;

    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.08);
    --warning: #ea580c;
    --warning-bg: rgba(234, 88, 12, 0.08);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --info: #0284c7;
    --info-bg: rgba(2, 132, 199, 0.08);

    /* White Theme */
    --bg-body: #f0f4f8;
    --bg-sidebar: #1e3a5f;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --bg-hover: rgba(37, 99, 235, 0.04);
    --bg-table-header: #f1f5f9;
    --bg-table-row-hover: rgba(37, 99, 235, 0.03);

    --border-color: #e2e8f0;
    --border-color-light: #cbd5e1;

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-white: #ffffff;

    /* Spacing */
    --sidebar-width: 260px;
    --header-height: 68px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);

    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

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

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

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e3a5f 0%, #1a3358 40%, #15294d 100%);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }

.sidebar-brand {
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand-logo {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800; color: #fff;
    flex-shrink: 0;
}

.sidebar-brand-logo img {
    width: 100%; height: 100%;
    border-radius: 10px;
    object-fit: cover;
}

.sidebar-brand-text {
    font-size: 14px; font-weight: 700;
    color: #fff; line-height: 1.3;
}

.sidebar-brand-text small {
    font-size: 11px; font-weight: 400;
    color: rgba(255,255,255,0.55);
    display: block;
}

.sidebar-menu { padding: 14px 10px; flex: 1; }

.sidebar-menu-label {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    padding: 12px 14px 8px;
}

.sidebar-menu a {
    display: flex; align-items: center;
    gap: 11px; padding: 11px 14px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.7);
    font-size: 13.5px; font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    position: relative;
}

.sidebar-menu a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    transform: translateX(3px);
}

.sidebar-menu a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-weight: 600;
}

.sidebar-menu a.active::before {
    content: '';
    position: absolute; left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 55%;
    background: #60a5fa;
    border-radius: 0 3px 3px 0;
}

.sidebar-menu a .icon {
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; flex-shrink: 0;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer a {
    display: flex; align-items: center;
    gap: 10px; padding: 10px 14px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    transition: var(--transition);
}

.sidebar-footer a:hover {
    background: rgba(220,38,38,0.15);
    color: #fca5a5;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1; min-height: 100vh;
    transition: var(--transition);
}

/* ===== TOP HEADER ===== */
.top-header {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.top-header-left {
    display: flex; align-items: center; gap: 14px;
}

.sidebar-toggle {
    display: none;
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 22px; cursor: pointer;
    padding: 8px; border-radius: 8px;
    transition: var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--bg-hover); color: var(--text-primary);
}

.page-title {
    font-size: 18px; font-weight: 700;
    color: var(--text-primary);
}

.page-title small {
    font-size: 13px; font-weight: 400;
    color: var(--text-muted); display: block;
    margin-top: 1px;
}

.top-header-right {
    display: flex; align-items: center; gap: 12px;
}

.admin-badge {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px 6px 6px;
    background: var(--bg-body);
    border-radius: 50px;
    font-size: 13px; color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.admin-badge .avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff;
}

/* ===== PAGE CONTENT ===== */
.page-content { padding: 28px; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-sm); }

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
    background: #fdfdfe;
}

.card-header h3 {
    font-size: 15px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
    color: var(--text-primary);
}

.card-body { padding: 22px; }

.card-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: flex-end;
    gap: 10px; background: #fafbfc;
}

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px; margin-bottom: 28px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex; align-items: flex-start; justify-content: space-between;
    transition: var(--transition);
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-card);
}

.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
}

.stat-card.blue::before { background: linear-gradient(90deg, #2563eb, #0ea5e9); }
.stat-card.green::before { background: linear-gradient(90deg, #16a34a, #22c55e); }
.stat-card.purple::before { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.stat-card.orange::before { background: linear-gradient(90deg, #ea580c, #f97316); }

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

.stat-info h4 {
    font-size: 12px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-info .stat-number {
    font-size: 30px; font-weight: 800;
    line-height: 1; margin-bottom: 4px;
}

.stat-card.blue .stat-number { color: var(--primary); }
.stat-card.green .stat-number { color: var(--success); }
.stat-card.purple .stat-number { color: #7c3aed; }
.stat-card.orange .stat-number { color: var(--warning); }

.stat-info .stat-label {
    font-size: 12px; color: var(--text-muted);
}

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

.stat-card.blue .stat-icon { background: var(--primary-bg); }
.stat-card.green .stat-icon { background: var(--success-bg); }
.stat-card.purple .stat-icon { background: rgba(124,58,237,0.08); }
.stat-card.orange .stat-icon { background: var(--warning-bg); }

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

table { width: 100%; border-collapse: collapse; }

table thead th {
    padding: 12px 14px;
    text-align: left;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-table-header);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

table tbody td {
    padding: 12px 14px;
    font-size: 13.5px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-secondary);
    vertical-align: middle;
}

table tbody tr { transition: var(--transition-fast); }
table tbody tr:hover { background: var(--bg-table-row-hover); }
table tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 50px;
    font-size: 11.5px; font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: #ecfdf5; color: #15803d; border: 1px solid #bbf7d0; }
.badge-danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-primary { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; padding: 9px 18px;
    border-radius: var(--radius);
    font-family: inherit; font-size: 13px; font-weight: 600;
    border: none; cursor: pointer;
    transition: var(--transition);
    white-space: nowrap; text-decoration: none;
    line-height: 1.4;
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(37,99,235,0.35);
    color: #fff;
}

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { box-shadow: 0 4px 14px rgba(22,163,74,0.35); color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { box-shadow: 0 4px 14px rgba(220,38,38,0.3); color: #fff; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { box-shadow: 0 4px 14px rgba(234,88,12,0.3); color: #fff; }

.btn-secondary {
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-body);
    color: var(--text-primary);
    border-color: var(--border-color-light);
}

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

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: var(--radius-lg); }
.btn-icon { padding: 7px; width: 34px; height: 34px; }

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

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

.form-group label {
    display: block;
    font-size: 13px; font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px; letter-spacing: 0.2px;
}

.form-group label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%; padding: 10px 14px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: inherit; font-size: 14px;
    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(--text-muted); }

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 12px; color: var(--text-muted); margin-top: 5px;
}

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

/* ===== FILE INPUT ===== */
.file-upload {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 22px; text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-input);
}

.file-upload:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.file-upload input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

.file-upload .icon { font-size: 28px; margin-bottom: 6px; }
.file-upload p { font-size: 12px; color: var(--text-muted); }
.file-upload .preview { margin-top: 10px; }
.file-upload .preview img { max-height: 70px; border-radius: 8px; }

/* ===== LINK BOX ===== */
.link-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 6px 6px 6px 14px;
}

.link-box input {
    flex: 1; background: none; border: none;
    color: var(--primary);
    font-family: 'Courier New', monospace;
    font-size: 13px; outline: none;
}

.link-box .btn-copy {
    padding: 7px 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.link-box .btn-copy:hover {
    background: var(--primary-dark);
}

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 50px 20px; }

.empty-state .icon { font-size: 48px; margin-bottom: 14px; opacity: 0.4; }

.empty-state h4 {
    font-size: 16px; font-weight: 600;
    margin-bottom: 6px; color: var(--text-secondary);
}

.empty-state p {
    font-size: 13px; color: var(--text-muted); margin-bottom: 18px;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }

.animate-fade-in { animation: fadeIn 0.4s ease; }
.animate-fade-in-up { animation: fadeInUp 0.5s ease; }
.animate-slide-in { animation: slideInRight 0.4s ease; }

.stats-grid .stat-card:nth-child(1) { animation: fadeInUp 0.4s ease 0.0s both; }
.stats-grid .stat-card:nth-child(2) { animation: fadeInUp 0.4s ease 0.1s both; }
.stats-grid .stat-card:nth-child(3) { animation: fadeInUp 0.4s ease 0.2s both; }
.stats-grid .stat-card:nth-child(4) { animation: fadeInUp 0.4s ease 0.3s both; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .sidebar-overlay {
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.3);
        z-index: 999; display: none;
    }
    .sidebar-overlay.show { display: block; }
}

@media (max-width: 768px) {
    .page-content { padding: 18px 14px; }
    .top-header { padding: 0 14px; }
    .card-header { padding: 14px 18px; }
    .card-body { padding: 18px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 16px; }
    .stat-info .stat-number { font-size: 22px; }
    .form-row { grid-template-columns: 1fr; }
    .btn-group { flex-direction: column; }
}

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

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

.login-page::before {
    content: '';
    position: absolute; width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(255,255,255,0.08), transparent 70%);
    top: -150px; right: -150px;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute; width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.06), transparent 70%);
    bottom: -100px; left: -100px;
    pointer-events: none;
}

.login-card {
    background: #ffffff;
    border-radius: var(--radius-xl);
    padding: 44px 36px;
    width: 100%; max-width: 420px;
    position: relative; z-index: 1;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: fadeInUp 0.6s ease;
}

.login-card .logo {
    text-align: center; margin-bottom: 28px;
}

.login-card .logo .logo-icon {
    width: 60px; height: 60px;
    background: linear-gradient(135deg, var(--primary), #0ea5e9);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; color: #fff;
    margin: 0 auto 14px;
}

.login-card .logo .logo-icon img {
    width: 100%; height: 100%;
    border-radius: 16px; object-fit: cover;
}

.login-card .logo h2 {
    font-size: 20px; font-weight: 700;
    color: var(--text-primary);
}

.login-card .logo p {
    font-size: 13px; color: var(--text-muted); margin-top: 4px;
}

.login-card .form-group { margin-bottom: 18px; }

.login-card .form-control {
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    font-size: 14px;
}

.login-card .btn-primary {
    width: 100%; padding: 12px;
    font-size: 15px; border-radius: var(--radius);
}

/* ===== MISC ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-warning { color: var(--warning); }
.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; }
.mr-1 { margin-right: 8px; }
.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%; }

.ttd-preview {
    max-height: 45px; max-width: 110px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: #fff;
}
