/* ============================
   Cliff Platform Design System
   Modern, clean with gradients & depth
   ============================ */

/* ---- CSS Custom Properties ---- */
:root {
    --color-primary: #4f46e5;
    --color-primary-dark: #3730a3;
    --color-primary-light: #818cf8;
    --color-accent: #06b6d4;
    --color-accent-dark: #0891b2;

    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-surface-alt: #f1f5f9;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;

    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;

    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;

    --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    --gradient-card: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    --gradient-header: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
    --gradient-score-high: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-score-mid: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-score-low: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --sidebar-width: 260px;
    --header-height: 64px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

/* ---- Layout ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--gradient-header);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.app-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

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

.sidebar-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(to right, #fff, #c7d2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-brand .version {
    font-size: 0.65rem;
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 999px;
    color: #c7d2fe;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.sidebar-nav .nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.4);
    padding: 16px 12px 6px;
    font-weight: 600;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.sidebar-nav a .nav-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    opacity: 0.8;
}

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

.sidebar-user img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-role {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
}

/* ---- Mobile hamburger ---- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--gradient-header);
    z-index: 101;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.hamburger {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
}

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

/* ---- Page Header ---- */
.page-header {
    background: var(--gradient-primary);
    padding: 32px 40px;
    color: white;
}

.page-header h2 {
    margin: 0 0 4px;
    font-size: 1.75rem;
    font-weight: 700;
}

.page-header p {
    margin: 0;
    opacity: 0.8;
    font-size: 0.95rem;
}

.page-body {
    padding: 32px 40px;
}

/* ---- Cards ---- */
.card {
    background: var(--gradient-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

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

.card-header {
    padding: 20px 24px 0;
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-text);
}

.card-body {
    padding: 20px 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-surface-alt);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

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

.stat-card.primary::before { background: var(--gradient-primary); }
.stat-card.success::before { background: var(--gradient-score-high); }
.stat-card.warning::before { background: var(--gradient-score-mid); }
.stat-card.danger::before { background: var(--gradient-score-low); }

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
    font-weight: 500;
}

.stat-card .stat-change {
    font-size: 0.8rem;
    margin-top: 8px;
    font-weight: 500;
}

/* ---- Score Badge ---- */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.score-badge.score-high { background: var(--gradient-score-high); }
.score-badge.score-mid { background: var(--gradient-score-mid); }
.score-badge.score-low { background: var(--gradient-score-low); }
.score-badge.score-none { background: var(--color-border); color: var(--color-text-muted); }

.score-badge-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.score-badge-lg {
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
}

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    background: var(--color-surface-alt);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.data-table th:hover {
    color: var(--color-primary);
}

.data-table th .sort-icon {
    margin-left: 4px;
    opacity: 0.4;
}

.data-table th.sorted .sort-icon {
    opacity: 1;
    color: var(--color-primary);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 0.9rem;
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.1s ease;
}

.data-table tbody tr:hover {
    background: rgba(79, 70, 229, 0.03);
}

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

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-sans);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    color: white;
}

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

.btn-secondary:hover {
    background: var(--color-surface-alt);
    border-color: var(--color-primary-light);
}

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

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

/* ---- Forms ---- */
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background: var(--color-surface);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

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

/* ---- Search ---- */
.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1), var(--shadow-sm);
}

.search-box .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
}

/* ---- Tags / Chips ---- */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.tag-primary {
    background: rgba(79, 70, 229, 0.1);
    color: var(--color-primary);
    border-color: rgba(79, 70, 229, 0.2);
}

.tag-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.2);
}

/* ---- Filters ---- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.filter-bar select {
    padding: 8px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font-sans);
    background: var(--color-surface);
    color: var(--color-text);
}

/* ---- Loading ---- */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.skeleton {
    background: linear-gradient(90deg, var(--color-surface-alt) 25%, var(--color-border-light) 50%, var(--color-surface-alt) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- Alerts / Flash ---- */
.alert {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

/* ---- Grid helpers ---- */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- Utility ---- */
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.15rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .page-body { padding: 24px 20px; }
    .page-header { padding: 24px 20px; }
}

@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

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

    .app-content {
        margin-left: 0;
        padding-top: var(--header-height);
    }

    .mobile-header {
        display: flex;
    }

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

    .grid-4, .grid-3, .grid-2 {
        grid-template-columns: 1fr;
    }

    .page-header h2 {
        font-size: 1.3rem;
    }

    .page-body {
        padding: 16px;
    }

    .page-header {
        padding: 20px 16px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th, .data-table td {
        padding: 10px 8px;
    }

    /* Hide less important columns on mobile */
    .hide-mobile {
        display: none;
    }
}

@media (max-width: 480px) {
    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .stat-card {
        padding: 16px;
    }
}
