/* ============================================
   7TH CAVALRY REGIMENT - SHARED STYLES
   Common CSS for all 7Cav web tools
   ============================================ */

/* ============================================
   CSS VARIABLES (Theme)
   ============================================ */
:root {
    /* Backgrounds */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: #16161f;
    --bg-input: #1a1a25;

    /* Accent Colors */
    --accent-primary: #3b82f6;
    --accent-secondary: #60a5fa;
    --accent-gold: #fbbf24;

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #8b8b9a;
    --text-muted: #5a5a6a;

    /* Borders */
    --border-color: #2a2a3a;

    /* Status Colors */
    --success: #00c853;
    --danger: #ff4655;
    --warning: #ffab00;

    /* Rank/Badge Colors (for ELO ranks, etc.) */
    --rank-iron: #7a7a7a;
    --rank-bronze: #cd7f32;
    --rank-silver: #c0c0c0;
    --rank-gold: #ffd700;
    --rank-platinum: #00d4aa;
    --rank-diamond: #b9f2ff;
    --rank-ascendant: #00ff87;
    --rank-immortal: #ff4655;
    --rank-radiant: #ffffa0;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
}

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

a:hover {
    color: var(--accent-secondary);
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: 2px;
}

.logo span {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 3px;
}

.nav-menu {
    padding: 16px 0;
    flex: 1;
}

.nav-section {
    padding: 12px 24px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    color: var(--text-secondary);
    text-decoration: none;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-tertiary);
    border-left-color: var(--accent-primary);
    color: var(--text-primary);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    margin-right: 12px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-secondary);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--accent-primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

tr:hover {
    background: var(--bg-tertiary);
}

/* Section Header Rows (for grouped tables) */
.section-header {
    background: var(--bg-secondary) !important;
}

.section-header td {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 14px;
    padding: 12px 16px;
    border-bottom: 2px solid var(--accent-primary);
}

/* ============================================
   FORM CONTROLS
   ============================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* Select dropdowns */
select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8b9a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Checkboxes */
.custom-checkbox {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.custom-checkbox .checkmark {
    width: 18px;
    height: 18px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.custom-checkbox input:checked ~ .checkmark {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.custom-checkbox input:checked ~ .checkmark::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

/* Form row grid layout */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

/* ============================================
   TABS
   ============================================ */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.2s;
}

.tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent-primary);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

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

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    background: var(--danger);
}

.toast.warning {
    background: var(--warning);
    color: #000;
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ============================================
   STATUS BADGES
   ============================================ */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active { background: rgba(0, 200, 83, 0.2); color: #00c853; }
.status-reserves { background: rgba(255, 171, 0, 0.2); color: #ffab00; }
.status-eloa { background: rgba(255, 171, 0, 0.2); color: #ffab00; }
.status-retired { background: rgba(139, 139, 154, 0.2); color: #8b8b9a; }
.status-discharged { background: rgba(139, 139, 154, 0.2); color: #8b8b9a; }
.status-dishonorable { background: rgba(200, 30, 40, 0.6); color: #fff; border: 1px solid #c81e28; }

/* ============================================
   RANK ICONS
   ============================================ */
.rank-icon-wrapper {
    width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rank-icon {
    height: 22px;
    width: auto;
    max-width: 32px;
    object-fit: contain;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--text-primary); }
.text-accent { color: var(--accent-primary); }
.text-gold { color: var(--accent-gold); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

.p-0 { padding: 0; }
.p-8 { padding: 8px; }
.p-12 { padding: 12px; }
.p-16 { padding: 16px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.hidden { display: none; }
.w-full { width: 100%; }

/* ============================================
   PROGRESS BARS
   ============================================ */
.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* ============================================
   PILOT / PLAYER INFO
   ============================================ */
.pilot-info, .player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pilot-name, .player-name {
    font-weight: 500;
}

.pilot-name a, .player-name a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.pilot-name a:hover, .player-name a:hover {
    color: var(--accent-primary);
}

/* ============================================
   WINGS DISPLAY (DCS specific, but commonly used)
   ============================================ */
.wings-display, .wings-toggle {
    width: 24px;
    height: auto;
    opacity: 0.3;
    filter: grayscale(100%);
    cursor: pointer;
    transition: all 0.2s;
}

.wings-display.active, .wings-toggle.active {
    opacity: 1;
    filter: grayscale(0%);
}

.wings-toggle:hover {
    transform: scale(1.1);
}

/* ============================================
   CALLSIGN STYLING
   ============================================ */
.callsign {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-gold);
}

.callsign.none {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
}

.callsign-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.callsign-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

.callsign-text {
    color: var(--accent-gold);
    font-weight: 600;
}

.origin-toggle {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 11px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.origin-toggle:hover {
    opacity: 1;
    color: var(--accent-gold);
}

.callsign-origin {
    display: none;
    font-size: 12px;
    color: var(--text-secondary);
    background: rgba(255, 215, 0, 0.05);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid var(--accent-gold);
    margin-top: 4px;
    font-style: italic;
}

.callsign-origin.show {
    display: block;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .main-content {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .tabs {
        flex-wrap: wrap;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .sidebar,
    .btn,
    .toast {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    body {
        background: white;
        color: black;
    }
}

/* ============================================
   AUTH / USER DISPLAY
   ============================================ */

/* Portal header auth widget */
.auth-display {
    position: absolute;
    top: 16px;
    right: 20px;
}

/* Sidebar user footer */
.sidebar-user {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

/* Shared auth widget styles */
.auth-widget--logged-in {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-widget-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.auth-widget-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.auth-widget-logout {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}

.auth-widget-logout:hover {
    color: var(--accent-danger, #ef4444);
    background: rgba(239, 68, 68, 0.1);
}

.auth-widget-login {
    background: var(--accent-primary);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.auth-widget-login:hover {
    opacity: 0.9;
}

/* ============================================
   RBAC / PERMISSION GATING
   ============================================ */

[data-requires-level] {
    display: none;
}

/* ============================================
   ANNOUNCEMENT BANNERS
   ============================================ */

.announcement-banner {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 500;
}

.announcement-info {
    background: rgba(59, 130, 246, 0.15);
    color: #93bbfc;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.announcement-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.announcement-urgent {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.announcement-dismiss {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.6;
}

.announcement-dismiss:hover {
    opacity: 1;
}

/* ============================================
   ADMIN PAGE
   ============================================ */

.billet-group-header {
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.08);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.billet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
}

.billet-row:hover {
    background: var(--bg-tertiary);
}

.billet-name {
    font-size: 0.85rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 12px;
}

.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-info {
    background: rgba(59, 130, 246, 0.2);
    color: #93bbfc;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.badge-urgent {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.78rem;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}
