/* =============================================
   ISG Concours - Stylesheet
   ============================================= */

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

:root {
    --primary: #1a365d;
    --primary-light: #2b4c7e;
    --primary-dark: #0f2440;
    --accent: #e63946;
    --accent-light: #ff6b6b;
    --success: #2d6a4f;
    --success-light: #40916c;
    --warning: #e09f3e;
    --danger: #c1121f;
    --info: #457b9d;
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1a365d;
    --text: #1d1d1f;
    --text-light: #6e6e73;
    --text-muted: #98989d;
    --border: #d2d2d7;
    --border-light: #e8e8ed;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
    --sidebar-width: 260px;
    --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    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; }

/* =============================================
   Login Page
   ============================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    padding: 20px;
}
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card h1 {
    font-size: 1.6rem;
    color: var(--primary);
    margin-bottom: 6px;
    font-weight: 700;
}
.login-card .subtitle {
    color: var(--text-light);
    margin-bottom: 32px;
    font-size: 0.93rem;
}
.login-card .logo-text {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

/* =============================================
   Layout
   ============================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header .brand {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.sidebar-header .role-badge {
    display: inline-block;
    background: rgba(255,255,255,0.15);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
}
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav .nav-section {
    padding: 8px 20px 4px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    margin-top: 8px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}
.sidebar-nav a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-left-color: var(--accent);
}
.sidebar-nav a .icon { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.8rem;
}
.sidebar-footer a { color: rgba(255,255,255,0.6); }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 0;
    min-height: 100vh;
}
.topbar {
    background: var(--bg-card);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-light);
    font-size: 0.87rem;
}
.topbar .user-info .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}
.page-content { padding: 28px 32px; }

/* =============================================
   Cards & Panels
   ============================================= */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}
.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}
.card-body { padding: 24px; }
.card-footer {
    padding: 16px 24px;
    background: #fafafa;
    border-top: 1px solid var(--border-light);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}
.stat-icon.blue { background: #e8f0fe; color: var(--primary); }
.stat-icon.green { background: #e6f4ea; color: var(--success); }
.stat-icon.red { background: #fce8e6; color: var(--accent); }
.stat-icon.orange { background: #fef3e2; color: var(--warning); }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text); }
.stat-label { font-size: 0.82rem; color: var(--text-light); }

/* =============================================
   Tables
   ============================================= */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}
table th {
    background: #f8f9fa;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
table tbody tr:hover { background: #f8f9fb; }
table td .actions { display: flex; gap: 6px; }

/* =============================================
   Forms
   ============================================= */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.87rem;
    color: var(--text);
}
.form-group label .required { color: var(--accent); }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.93rem;
    font-family: var(--font);
    color: var(--text);
    background: #fff;
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,54,93,0.1);
}
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 100px; resize: vertical; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.form-help {
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =============================================
   Buttons
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none !important;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-secondary { background: #e8e8ed; color: var(--text); }
.btn-secondary:hover { background: #d2d2d7; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: #f8f9fa; }

/* =============================================
   Alerts & Flash
   ============================================= */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: #e6f4ea; color: var(--success); border: 1px solid #b7e1cd; }
.alert-error { background: #fce8e6; color: var(--danger); border: 1px solid #f4c7c3; }
.alert-warning { background: #fef3e2; color: #8a6d3b; border: 1px solid #f5e1be; }
.alert-info { background: #e8f0fe; color: var(--info); border: 1px solid #b6d4fe; }

/* =============================================
   Badges
   ============================================= */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-primary { background: #e8f0fe; color: var(--primary); }
.badge-success { background: #e6f4ea; color: var(--success); }
.badge-danger { background: #fce8e6; color: var(--danger); }
.badge-warning { background: #fef3e2; color: #8a6d3b; }
.badge-info { background: #e0f2fe; color: var(--info); }
.badge-secondary { background: #f0f0f0; color: var(--text-light); }

/* =============================================
   Pagination
   ============================================= */
.pagination-nav { margin-top: 20px; text-align: center; }
.pagination {
    display: inline-flex;
    list-style: none;
    gap: 4px;
}
.pagination li a {
    display: block;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text);
}
.pagination li.active a {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination li a:hover { background: #f0f0f0; text-decoration: none; }

/* =============================================
   Filters bar
   ============================================= */
.filters-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: var(--radius-sm);
}
.filters-bar .form-control {
    width: auto;
    min-width: 160px;
}
.filters-bar .btn { white-space: nowrap; }

/* =============================================
   Empty state
   ============================================= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 1rem; }

/* =============================================
   Modal (simple)
   ============================================= */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h3 { margin-bottom: 16px; }
.modal .modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); transition: var(--transition); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar { padding: 12px 16px; }
    .page-content { padding: 20px 16px; }
    .form-row { grid-template-columns: 1fr; }
}

/* =============================================
   Utilities
   ============================================= */
.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); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }

/* =============================================
   Searchable Select
   ============================================= */
.ss-wrapper {
    position: relative;
    width: 100%;
}
.ss-display {
    position: relative;
    cursor: pointer;
    user-select: none;
    padding-right: 32px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ss-display.ss-placeholder { color: var(--text-muted); }
.ss-display.ss-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,54,93,0.1);
}
.ss-chevron {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    pointer-events: none;
}
.ss-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 200;
    max-height: 320px;
    overflow: hidden;
    flex-direction: column;
}
.ss-dropdown.ss-open { display: flex; }
.ss-search {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    font-family: var(--font);
    outline: none;
    background: #f8f9fa;
    color: var(--text);
}
.ss-search::placeholder { color: var(--text-muted); }
.ss-list {
    overflow-y: auto;
    max-height: 260px;
    overscroll-behavior: contain;
}
.ss-item {
    padding: 9px 14px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text);
    transition: background 0.1s;
    border-bottom: 1px solid var(--border-light);
}
.ss-item:last-child { border-bottom: none; }
.ss-item:hover, .ss-item.ss-hover {
    background: #e8f0fe;
    color: var(--primary);
}
.ss-item.ss-selected {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}
.ss-item.ss-selected:hover {
    background: var(--primary-light);
    color: #fff;
}
.ss-empty {
    padding: 16px 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}
