/* CHIPPC License Server - Design System v2.0 */
/* Matching Xcalibur main project colors      */
/* ============================================ */

/* ---- CSS Variables / Theming ---- */
:root {
    --primary: #003678;
    --primary-light: #70D4FF;
    --primary-dark: #002554;
    --secondary: #70D4FF;
    --accent: #E9F8FF;
    --success: #A6CE39;
    --success-light: rgba(166, 206, 57, 0.15);
    --warning: #FCB914;
    --warning-light: rgba(252, 185, 20, 0.15);
    --danger: #ec008c;
    --danger-light: rgba(236, 0, 140, 0.12);
    --info: #003678;
    --info-light: rgba(0, 54, 120, 0.1);

    --bg: #fdfeff;
    --bg-card: #ffffff;
    --bg-input: #f4f7fa;
    --border: #BDBDBD;
    --border-light: #e9f8ff;
    --text: #003678;
    --text-light: #5a6f8a;
    --text-lighter: #999999;
    --shadow-sm: 0 1px 2px rgba(0, 54, 120, 0.06);
    --shadow: 0 1px 3px rgba(0, 54, 120, 0.1), 0 1px 2px rgba(0, 54, 120, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 54, 120, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 54, 120, 0.15);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

/* ---- Dark Mode ---- */
body.dark {
    --primary: #70D4FF;
    --primary-light: #a0e4ff;
    --primary-dark: #003678;
    --secondary: #003678;
    --accent: #1a1a2e;
    --success: #A6CE39;
    --success-light: rgba(166, 206, 57, 0.2);
    --warning: #FCB914;
    --warning-light: rgba(252, 185, 20, 0.2);
    --danger: #ff4da6;
    --danger-light: rgba(236, 0, 140, 0.2);
    --info: #70D4FF;
    --info-light: rgba(112, 212, 255, 0.15);

    --bg: #16213e;
    --bg-card: #0f3460;
    --bg-input: #1a2d52;
    --border: #2a4070;
    --border-light: #1a2d52;
    --text: #ffffff;
    --text-light: #a0b4cc;
    --text-lighter: #6a7f99;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ---- Navigation Bar ---- */
.nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: #003678;
    border-bottom: none;
    box-shadow: 0 2px 8px rgba(0, 54, 120, 0.25);
    position: sticky;
    top: 0;
    z-index: 100;
}
body.dark .nav-bar { background: #0a1929; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }

.nav-left { display: flex; align-items: center; gap: 16px; }
.nav-right { display: flex; align-items: center; gap: 8px; }

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
    color: #ffffff;
}
.nav-brand svg { stroke: #70D4FF; }

.nav-links { display: flex; gap: 4px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none !important;
}
.nav-link svg { stroke: rgba(255,255,255,0.7); }
.nav-link:hover { background: rgba(255,255,255,0.1); color: #ffffff; }
.nav-link:hover svg { stroke: #ffffff; }
.nav-link.active { background: #70D4FF; color: #003678; font-weight: 600; }
.nav-link.active svg { stroke: #003678; }

.nav-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.7);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}
.nav-icon-btn:hover { background: rgba(255,255,255,0.1); color: #ffffff; }

.nav-user {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    padding: 0 8px;
}
.nav-user svg { stroke: rgba(255,255,255,0.5); }

.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    border-radius: var(--radius);
}

/* ---- Page Container ---- */
.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}
.stat-card .stat-icon {
    float: right;
    color: #70D4FF;
    opacity: 0.7;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: #003678; color: white; }
.btn-primary:hover:not(:disabled) { background: #002554; }
body.dark .btn-primary { background: #70D4FF; color: #0a1929; }
body.dark .btn-primary:hover:not(:disabled) { background: #a0e4ff; }

.btn-success { background: #A6CE39; color: white; }
.btn-success:hover:not(:disabled) { filter: brightness(0.9); }

.btn-danger { background: #ec008c; color: white; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.85); }

.btn-warning { background: #FCB914; color: #003678; }

.btn-outline {
    background: var(--bg-card);
    color: var(--text-light);
    border: 1px solid var(--border);
}
.btn-outline:hover:not(:disabled) { background: var(--accent); color: #003678; border-color: #70D4FF; }

.btn-ghost { background: transparent; color: var(--text-light); }
.btn-ghost:hover { background: var(--bg-input); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

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

/* ---- Table ---- */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
    flex-wrap: wrap;
}

.table-toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.table-toolbar-right { display: flex; align-items: center; gap: 8px; }

.table-scroll { overflow-x: auto; }

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

th, td {
    padding: 10px 14px;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
}

th {
    background: #E9F8FF;
    font-weight: 600;
    color: #003678;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    user-select: none;
    position: sticky;
    top: 0;
}
body.dark th { background: #0a1929; color: #70D4FF; }

th.sortable { cursor: pointer; }
th.sortable:hover { color: #70D4FF; }
th .sort-icon { font-size: 10px; margin-left: 4px; }

tr:hover td { background: #E9F8FF; }
body.dark tr:hover td { background: rgba(112,212,255,0.05); }
tr:last-child td { border-bottom: none; }

.table-empty {
    text-align: center;
    padding: 48px;
    color: var(--text-lighter);
    font-size: 14px;
}

.table-actions { display: flex; gap: 4px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], input[type="datetime-local"],
textarea, select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--bg-input);
    color: var(--text);
    transition: var(--transition);
    line-height: 1.4;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #70D4FF;
    box-shadow: 0 0 0 3px rgba(112, 212, 255, 0.2);
}

.search-input {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 4px 12px;
    max-width: 300px;
}
.search-input input {
    border: none;
    background: transparent;
    padding: 4px 0;
    font-size: 13px;
    outline: none;
    width: 100%;
    color: var(--text);
    box-shadow: none !important;
}
.search-input svg { color: var(--text-lighter); flex-shrink: 0; }

select.filter-select {
    width: auto;
    min-width: 120px;
    padding: 6px 10px;
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.6;
}
.badge-success { background: rgba(166,206,57,0.15); color: #5a8a00; }
.badge-danger { background: rgba(236,0,140,0.12); color: #c0007a; }
.badge-warning { background: rgba(252,185,20,0.15); color: #8a6200; }
.badge-info { background: rgba(0,54,120,0.1); color: #003678; }
.badge-neutral { background: var(--bg-input); color: var(--text-light); }

body.dark .badge-success { background: rgba(166,206,57,0.2); color: #c5e85c; }
body.dark .badge-danger { background: rgba(236,0,140,0.2); color: #ff6ebf; }
body.dark .badge-warning { background: rgba(252,185,20,0.2); color: #fdd55a; }
body.dark .badge-info { background: rgba(112,212,255,0.15); color: #70D4FF; }
body.dark .badge-neutral { background: #1a2d52; color: #6a7f99; }

/* ---- Modal ---- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 54, 120, 0.35);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    animation: modalIn 0.2s ease;
}

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

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ---- Quick Period Buttons ---- */
.quick-periods {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    transform: translateY(10px);
    opacity: 0;
    transition: all 0.3s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: #A6CE39; }
.toast-error { background: #ec008c; }
.toast-warning { background: #FCB914; color: #003678; }

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
}
.pagination-info {
    font-size: 13px;
    color: var(--text-light);
}

/* ---- Results Counter ---- */
.results-count {
    font-size: 12px;
    color: var(--text-lighter);
    padding: 4px 8px;
}

/* ---- Login Page ---- */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #003678 0%, #0f3460 50%, #16213e 100%);
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 54, 120, 0.3);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #003678;
}

.login-card .subtitle {
    text-align: center;
    color: #5a6f8a;
    font-size: 14px;
    margin-bottom: 28px;
}

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

.login-card .btn-primary {
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    background: #003678;
    color: white;
}
.login-card .btn-primary:hover { background: #002554; }

.login-error {
    background: rgba(236,0,140,0.12);
    color: #c0007a;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

/* ---- Health status ---- */
.health-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-lighter);
}
.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #A6CE39;
}
.health-dot.error { background: #ec008c; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .hamburger { display: flex; }
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: #003678;
        border-bottom: 3px solid #70D4FF;
        flex-direction: column;
        padding: 8px;
        box-shadow: var(--shadow-md);
    }
    body.dark .nav-links { background: #0a1929; }
    .nav-links.mobile-open { display: flex; }
    .nav-user { display: none; }
    .page-container { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .search-input { max-width: 100%; }
}

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