/* ============================================================
   NATION FORGE - MAIN STYLESHEET
   Dark Forge Theme (Consistent across ALL pages)
   Bootstrap 5 Compatible + Mobile Responsive
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Cinzel+Decorative:wght@700&family=Rajdhani:wght@400;500;600;700&display=swap');

:root {
    /* Dark Forge Theme Colors */
    --forge-bg: #060c14;
    --forge-surface: #0d1826;
    --forge-panel: #0e1d30;
    --forge-border: rgba(80,130,220,0.22);
    --forge-border-hi: rgba(180,210,255,0.7);
    --forge-blue: #5090e0;
    --forge-blue-hi: #90c0ff;
    --forge-glow: rgba(60,120,255,0.18);
    --forge-gold: #c8a84b;
    --forge-gold-dim: rgba(200,168,75,0.4);
    --forge-red: #c0473a;
    --forge-green: #3a9e60;
    --text-bright: #e8f2ff;
    --text-mid: #8ab0d8;
    --text-dim: #4a6880;
    --font-title: 'Cinzel', serif;
    --font-body: 'Rajdhani', sans-serif;
    
    /* Legacy variables (kept for compatibility) */
    --primary: #0b3c5d;
    --primary-dark: #072a42;
    --secondary: #0099f1;
    --secondary-dark: #0077cc;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --bg: #eef3f8;
    --card-bg: rgba(14, 26, 44, 0.92);
    --border: rgba(80,130,220,0.22);
    --text-main: var(--text-bright);
    --text-secondary: var(--text-mid);
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --overlay-dark: rgba(0, 0, 0, 0.55);
    --overlay-light: rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* ============================================================
   GLOBAL BACKGROUND - DARK FORGE THEME (ALL PAGES)
   ============================================================ */
body {
    font-family: var(--font-body);
    color: var(--text-bright);
    line-height: 1.5;
    min-height: 100vh;
    background: var(--forge-bg);
    background-attachment: fixed;
    position: relative;
}

/* Forge background pattern (subtle grid) */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 59px, rgba(80,130,220,0.03) 60px),
        repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(80,130,220,0.03) 60px),
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(20,50,110,0.25) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
}

/* Dark overlay for readability */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-dark);
    z-index: -1;
    pointer-events: none;
}

/* Page-specific background enhancements (subtle variations) */
body.nation-page::before {
    background-image: repeating-linear-gradient(0deg, transparent, transparent 59px, rgba(80,130,220,0.04) 60px),
                      repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(80,130,220,0.04) 60px),
                      radial-gradient(ellipse 70% 50% at 30% 80%, rgba(0,100,200,0.08) 0%, transparent 60%);
}
body.provinces-page::before {
    background-image: repeating-linear-gradient(0deg, transparent, transparent 59px, rgba(60,180,110,0.03) 60px),
                      repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(60,180,110,0.03) 60px);
}
body.economy-page::before {
    background-image: repeating-linear-gradient(0deg, transparent, transparent 59px, rgba(200,168,75,0.03) 60px),
                      repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(200,168,75,0.03) 60px);
}
body.research-page::before {
    background-image: repeating-linear-gradient(0deg, transparent, transparent 59px, rgba(150,100,200,0.03) 60px),
                      repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(150,100,200,0.03) 60px);
}

/* Login page - lighter overlay for better readability */
body.login-page::after {
    background: var(--overlay-light);
}

/* Background image support */
body.has-bg {
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
}

/* ============================================================
   CARD BACKGROUNDS (Semi-transparent for forge feel)
   ============================================================ */
.card,
.stat-card,
.building-card,
.province-tab,
.province-stat-card,
.nsec,
.nsb-sec,
.construction-queue-section,
.rp-card,
.rp-active-box,
.rp-unlocked-box,
.nation-cover,
.login-card,
.modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--forge-border);
    border-radius: var(--radius-md);
}

/* Top bars - slightly more solid */
.top-bar,
.nav-menu,
.resource-bar,
.nation-meta-bar,
.nfh-top,
.nfh-resbar,
.nfh-nav {
    background: rgba(11, 60, 93, 0.95);
    backdrop-filter: blur(4px);
    border-bottom: 1px solid var(--forge-border);
}

/* ============================================================
   BOOTSTRAP 5 OVERRIDES
   ============================================================ */
.modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--forge-border);
    color: var(--text-bright);
}

.modal-header {
    border-bottom-color: var(--forge-border);
}

.modal-footer {
    border-top-color: var(--forge-border);
}

.modal-title {
    color: var(--text-bright);
    font-family: var(--font-title);
}

.btn-close {
    filter: invert(1) brightness(1.5);
}

/* ============================================================
   TOP BAR (Mobile Responsive)
   ============================================================ */
.top-bar {
    background: var(--primary);
    color: white;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.game-logo {
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--font-title);
}

.game-logo:hover { color: var(--secondary); }

.top-bar-right {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.top-stat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
}

/* ============================================================
   RESOURCE BAR (Mobile Responsive)
   ============================================================ */
.resource-bar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--forge-border);
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.8rem;
}

.resource-item {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 20px;
    transition: background 0.2s;
}

.resource-item:hover {
    background: rgba(80,130,220,0.15);
}

/* ============================================================
   NAVIGATION MENU (Mobile Responsive - Hamburger)
   ============================================================ */
.nav-menu {
    background: var(--secondary);
    padding: 0;
    position: relative;
}

/* Desktop navigation */
.nav-links {
    display: flex;
    list-style: none;
    gap: 0;
    margin: 0;
    padding: 0;
}

.nav-links li a {
    display: inline-block;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
}

.nav-links li a:hover { background: rgba(255,255,255,0.15); }
.nav-links li a.active { background: white; color: var(--secondary); }

/* Mobile hamburger button - hidden on desktop */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 10px 16px;
    cursor: pointer;
}

/* Mobile responsive navigation */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        background: var(--secondary);
    }
    
    .nav-links.show {
        display: flex;
    }
    
    .nav-links li a {
        display: block;
        padding: 12px 20px;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
}

/* ============================================================
   MAIN CONTAINER (Mobile Responsive)
   ============================================================ */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

@media (max-width: 768px) {
    .main-container {
        padding: 12px;
    }
}

/* ============================================================
   PROVINCE TABS (Mobile Responsive)
   ============================================================ */
.province-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.province-tab {
    background: var(--card-bg);
    border: 1px solid var(--forge-border);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    text-align: center;
    text-decoration: none;
    color: var(--text-bright);
    transition: all 0.2s;
    min-width: 80px;
    flex: 1 0 auto;
}

@media (max-width: 576px) {
    .province-tabs {
        flex-direction: column;
    }
    
    .province-tab {
        width: 100%;
    }
}

.province-tab:hover { background: rgba(80,130,220,0.15); border-color: var(--forge-blue); }
.province-tab.active { background: var(--secondary); color: white; border-color: var(--secondary); }

.province-tab-icon { font-size: 1.3rem; margin-bottom: 4px; }
.province-tab-name { font-weight: 600; font-size: 0.85rem; }

/* ============================================================
   PROVINCE STATS GRID (Mobile Responsive)
   ============================================================ */
.province-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

@media (max-width: 576px) {
    .province-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

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

.province-stat-card {
    background: var(--card-bg);
    border: 1px solid var(--forge-border);
    border-radius: var(--radius-md);
    padding: 10px;
    text-align: center;
}

/* ============================================================
   BUILDINGS SCROLL (Mobile Responsive)
   ============================================================ */
.buildings-scroll {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 24px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.building-card {
    background: var(--card-bg);
    border: 0.5px solid var(--forge-border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 180px;
    width: 180px;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
}

@media (max-width: 576px) {
    .building-card {
        min-width: 160px;
        width: 160px;
    }
}

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

.building-card-img {
    height: 80px;
    overflow: hidden;
    background: rgba(8,16,28,0.8);
}

@media (max-width: 576px) {
    .building-card-img {
        height: 70px;
    }
}

.building-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.building-card-label {
    background: var(--secondary);
    color: #fff;
    text-align: center;
    font-size: 10px;
    font-weight: 500;
    padding: 4px 6px;
}

.building-card-stats {
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.bstat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    padding: 3px 0;
    border-bottom: 0.5px solid var(--forge-border);
}

.bstat:last-child { border-bottom: none; }

.bstat-neg { color: var(--forge-red); font-weight: 500; }
.bstat-pos { color: var(--forge-green); font-weight: 500; }
.bstat-neu { color: var(--text-mid); }
.bstat-muted { color: var(--text-dim); }

.building-card-owned-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: rgba(8,16,28,0.5);
    border-top: 0.5px solid var(--forge-border);
}

.building-card-owned-label {
    font-size: 10px;
    color: var(--text-dim);
}

.building-card-owned-count {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-bright);
}

.building-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 6px 8px;
    border-top: 0.5px solid var(--forge-border);
}

.btn-build-sm,
.btn-destroy-sm,
.btn-details-sm {
    font-size: 10px;
    padding: 5px 0;
}

/* ============================================================
   MODALS (Mobile Responsive)
   ============================================================ */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 8px;
    }
    
    .modal-content {
        border-radius: var(--radius-md);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 12px;
    }
    
    .modal-title {
        font-size: 1.1rem;
    }
}

/* ============================================================
   FORMS (Mobile Responsive)
   ============================================================ */
.form-control,
.form-select {
    font-size: 16px;
    background: rgba(8,16,28,0.8);
    border: 1px solid var(--forge-border);
    color: var(--text-bright);
}

.form-control:focus,
.form-select:focus {
    background: rgba(20,40,80,0.6);
    border-color: var(--forge-blue);
    box-shadow: 0 0 0 2px rgba(80,140,220,0.1);
    color: var(--text-bright);
}

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

@media (max-width: 768px) {
    .form-group {
        margin-bottom: 15px;
    }
    
    label {
        font-size: 0.85rem;
        color: var(--text-mid);
    }
}

/* ============================================================
   BUTTONS (Mobile Responsive)
   ============================================================ */
.btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

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

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

@media (max-width: 576px) {
    .btn {
        padding: 10px 14px;
        width: 100%;
        margin-bottom: 5px;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
}

/* ============================================================
   LOGIN PAGE (Mobile Responsive) - Dark Forge Theme
   ============================================================ */
.login-container {
    max-width: 450px;
    margin: 40px auto;
    background: linear-gradient(180deg, rgba(14,26,44,0.95) 0%, rgba(10,18,34,0.98) 100%);
    border: 1px solid var(--forge-border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 1px 0 rgba(160,200,255,0.05);
    backdrop-filter: blur(12px);
}

@media (max-width: 576px) {
    .login-container {
        margin: 20px;
        padding: 20px;
    }
    
    .login-header h2 {
        font-size: 1.5rem;
    }
}

/* ============================================================
   TABLES (Mobile Responsive)
   ============================================================ */
.table {
    color: var(--text-bright);
}

.table thead th {
    border-bottom-color: var(--forge-border);
    color: var(--text-mid);
}

.table td, .table th {
    border-color: var(--forge-border);
}

@media (max-width: 768px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 8px 10px;
    }
}

/* ============================================================
   FOOTER STYLES
============================================================ */
.footer {
    background: rgba(11, 60, 93, 0.95);
    color: rgba(255, 255, 255, 0.7);
    padding: 15px 20px;
    text-align: center;
    font-size: 0.75rem;
    margin-top: 30px;
    backdrop-filter: blur(4px);
    border-top: 1px solid var(--forge-border);
}

.footer .container {
    max-width: 1200px;
    margin: 0 auto;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.75rem;
    transition: color 0.2s;
    padding: 4px 8px;
    border-radius: 20px;
}

.social-link:hover {
    color: var(--forge-blue);
}

.social-link svg {
    width: 14px;
    height: 14px;
}

/* Responsive footer */
@media (max-width: 576px) {
    .footer {
        padding: 12px 15px;
    }
    
    .social-links {
        gap: 12px;
    }
    
    .social-link {
        font-size: 0.7rem;
    }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-dim); }
.text-white { color: white; }
.text-primary { color: var(--forge-blue); }
.text-success { color: var(--forge-green); }
.text-danger { color: var(--forge-red); }
.text-warning { color: var(--forge-gold); }

.mt-1 { margin-top: 5px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 15px; }
.mt-4 { margin-top: 20px; }
.mt-5 { margin-top: 30px; }

.mb-1 { margin-bottom: 5px; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 15px; }
.mb-4 { margin-bottom: 20px; }
.mb-5 { margin-bottom: 30px; }

.p-1 { padding: 5px; }
.p-2 { padding: 10px; }
.p-3 { padding: 15px; }
.p-4 { padding: 20px; }
.p-5 { padding: 30px; }

.w-100 { width: 100%; }
.w-50 { width: 50%; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.justify-content-center { justify-content: center; }
.align-items-center { align-items: center; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.alert-success {
    background: rgba(58, 158, 96, 0.15);
    border: 1px solid var(--forge-green);
    color: #7ad89a;
}

.alert-danger {
    background: rgba(192, 71, 58, 0.15);
    border: 1px solid var(--forge-red);
    color: #f09090;
}

.alert-warning {
    background: rgba(200, 168, 75, 0.15);
    border: 1px solid var(--forge-gold);
    color: #e8c86a;
}

.alert-info {
    background: rgba(80, 144, 224, 0.15);
    border: 1px solid var(--forge-blue);
    color: #90c0ff;
}

/* ============================================================
   LINK STYLES
   ============================================================ */
a {
    color: var(--forge-blue);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--forge-blue-hi);
}

/* ============================================================
   RESPONSIVE BREAKPOINTS SUMMARY
   ============================================================ */
/* 
   Desktop: 1200px+ - Full layout
   Tablet: 768px - 1199px - Adjusted spacing
   Mobile: 576px - 767px - Stacked layout
   Small Mobile: < 576px - Full width, larger touch targets
*/