/* assets/css/style.css - Rugged Trail (Variable-Driven Architecture) */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=JetBrains+Mono:wght@300;400;500;700&display=swap');

:root {
    /* === Color System === */
    --bg-color: #e8dfd5;
    --bg-panel: #f5eedf;
    --brand-green: #32380f;
    --brand-green-light: #666e3c;
    --ink: #2d2a26;
    --ink-soft: #5c554b;
    --ink-faint: #b8ac99;
    --line: #c4b8a5;
    --line-rabat: #fffcf8;
    --accent: #9c4a1a;
    --accent2: #9c291a;
    --accent-hover: #7a3a14;
    --ok: #3e6b27;
    --danger: #8c251c;
    --rh3red: #C00000;
    /* === Typography === */
    --font-primary: 'Cinzel', serif;
    --font-secondary: 'JetBrains Mono', monospace;

    /* === Dimensions & Layout === */
    --header-height: 80px;
    --content-max-width: 1200px;

    /* === Logo Math === */
    --logo-scale: 1.4;
    --logo-height: calc(var(--header-height) * var(--logo-scale));
    --logo-margin-top: 10px;
    /* Positions it nicely from the top of the fixed-height container */
    --logo-clearance: calc(var(--logo-height) + 20px);
    /* Ensure text fully clears the circular logo */

    /* === Borders & Shadows === */
    --border-width: 2px;
    --border-radius: 2px;
    --shadow-color: rgba(45, 42, 38, 0.15);
    --shadow-heavy: rgba(0, 0, 0, 0.6);
    --shadow-offset: 4px;
    --box-shadow: var(--shadow-offset) var(--shadow-offset) 0px var(--shadow-color);

    /* === Textures === */
    --bg-texture: radial-gradient(circle at center, transparent 0%, rgba(45, 42, 38, 0.05) 100%);
}

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

html,
body {
    overflow-x: clip;
    width: 100%;
}

body {
    font-family: var(--font-secondary);
    background-color: var(--bg-color);
    background-image: var(--bg-texture);
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Scrollbars === */
::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

::-webkit-scrollbar-track {
    background: var(--line);
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border: 2px solid var(--line);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

h1,
h2,
h3,
h4,
h5,
h6,
.cinzel,
.card-title,
.numeric-value {
    font-family: var(--font-primary);
    font-weight: 700;
}

/* === Layout Shell === */
.app-header {
    /* 
       We layer an 85% opaque solid block of the Brand Green (rgb 75, 83, 32) 
       directly on top of the image to push the texture opacity down to 15%.
    */
    background:
        var(--header-bg, linear-gradient(rgba(75, 83, 32, 0.95), rgba(75, 83, 32, 0.95)), url('../img/header-texture.png')) repeat;
    background-color: var(--header-overlay-color, var(--brand-green));
    color: var(--bg-panel);
    border-bottom: calc(var(--border-width) * 2) solid var(--accent);
    padding: 0 2rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 var(--shadow-offset) calc(var(--shadow-offset) * 2.5) rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.main-content {
    flex: 1;
    padding: 5.5rem 2rem 3rem 2rem;
    max-width: var(--content-max-width);
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
}

/* === Branding & Logo === */
.brand-logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    position: relative;
    height: var(--header-height);
}

.brand-logo-img {
    height: 50px;
    width: 50px;
    background-color: var(--accent);
    border-radius: 50%;
    padding: 3px;
    object-fit: contain;
}

.app-header .brand-logo-img {
    position: absolute;
    left: 0;
    top: var(--logo-margin-top);
    height: var(--logo-height);
    width: var(--logo-height);
    box-shadow: 4px 4px 6px var(--shadow-heavy);
    z-index: 1000;
}

.app-header .brand-logo-text {
    margin-left: var(--logo-clearance);
}

.brand-logo-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-transform: uppercase;
    font-family: var(--font-primary);
    line-height: 1.1;
    text-shadow: calc(var(--border-width)) calc(var(--border-width)) 0 var(--ink);
    padding-left: 20px;
}

.brand-logo-line1 {
    font-weight: 600;
    color: var(--line-rabat);
    font-size: 1.6rem;
    letter-spacing: 0.62em;
}

.brand-logo-line2 {
    font-size: 1.1rem;
    color: var(--bg-panel);
    letter-spacing: 1px;
}

/* === Navigation === */
.nav-menu {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-item {
    color: rgba(245, 238, 223, 0.7);
    text-decoration: none;
    font-size: 0.95rem;
    font-family: var(--font-secondary);
    font-weight: 700;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
    text-transform: uppercase;
}

.nav-item:hover {
    color: #fff;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius);
}

.nav-item.active {
    color: #fff;
    background-color: var(--accent);
    border-radius: var(--border-radius);
    box-shadow: var(--border-width) var(--border-width) 0 var(--ink);
}

/* === Desktop Dropdowns === */
.nav-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.nav-dropdown-trigger {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}

.nav-dropdown-trigger i.fa-chevron-down {
    font-size: 0.7rem;
    transition: transform 0.25s ease;
    opacity: 0.85;
}

.nav-dropdown:hover .nav-dropdown-trigger i.fa-chevron-down {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 210px;
    background: linear-gradient(rgba(45, 42, 38, 0.98), rgba(45, 42, 38, 0.98)), url('../img/header-texture.png') repeat;
    background-color: var(--ink);
    border: calc(var(--border-width) * 1.5) solid var(--accent);
    border-radius: var(--border-radius);
    padding: 0.35rem 0;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1100;
    overflow: hidden;
    box-sizing: border-box;
}

/* Dropdown alignment helper for last items */
.nav-dropdown.dropdown-right .nav-dropdown-menu {
    left: auto;
    right: 0;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(2px);
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.15rem;
    margin: 0;
    color: rgba(245, 238, 223, 0.88);
    text-decoration: none !important;
    font-family: var(--font-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.3;
    transition: background 0.15s, color 0.15s;
    text-transform: none;
    box-sizing: border-box;
    width: 100%;
    border: none !important;
    white-space: nowrap;
}

.nav-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    text-decoration: none !important;
}

.nav-dropdown-item.active {
    background: rgba(225, 219, 214, 0.18);
    color: #ffffff;
    border-left: 4px solid var(--accent) !important;
    font-weight: 700;
}

/* === Mobile Navigation System === */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--bg-panel);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-nav-drawer {
    position: fixed;
    top: 0;
    right: -340px;
    width: 320px;
    max-width: min(320px, calc(100vw - 32px));
    height: 100vh;
    height: 100dvh;
    background:
        var(--header-bg, linear-gradient(rgba(75, 83, 32, 0.95), rgba(75, 83, 32, 0.95)), url('../img/header-texture.png')) repeat;
    background-color: var(--header-overlay-color, var(--brand-green));
    border-left: calc(var(--border-width) * 2) solid var(--accent);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.mobile-nav-header {
    height: var(--header-height);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: calc(var(--border-width) * 2) solid var(--accent);
    flex-shrink: 0;
}

.mobile-menu-close {
    background: transparent;
    border: none;
    color: var(--bg-panel);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
}

.mobile-nav-links {
    padding: 0.75rem 0.65rem 2rem 0.65rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}

.mobile-nav-links > .nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-radius: var(--border-radius);
    border-bottom: var(--border-width) solid rgba(245, 238, 223, 0.1);
    color: rgba(245, 238, 223, 0.9);
    text-transform: uppercase;
    font-weight: 700;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    min-height: 42px;
    box-sizing: border-box;
}

.mobile-nav-links > .nav-item > i {
    width: 1.25rem;
    min-width: 1.25rem;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.9;
}

.mobile-nav-links > .nav-item > span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.mobile-nav-links > .nav-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.mobile-nav-links > .nav-item.active {
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    border-left: 3px solid var(--accent);
}

/* Mobile Accordion Groups */
.mobile-nav-group {
    border: var(--border-width) solid rgba(245, 238, 223, 0.15);
    border-radius: var(--border-radius);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.12);
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
    box-sizing: border-box;
}

.mobile-nav-group.open {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(245, 238, 223, 0.25);
}

.mobile-nav-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0.75rem;
    color: rgba(245, 238, 223, 0.95);
    font-family: var(--font-secondary);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    user-select: none;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
    min-height: 42px;
    box-sizing: border-box;
}

.mobile-nav-accordion-header > span {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-nav-accordion-header > span > i {
    width: 1.25rem;
    min-width: 1.25rem;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.9;
}

.mobile-nav-accordion-header:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.mobile-nav-group.open .mobile-nav-accordion-header {
    border-bottom: 1px solid rgba(245, 238, 223, 0.15);
    color: #ffffff;
}

.mobile-nav-accordion-header i.fa-chevron-down {
    font-size: 0.75rem;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.mobile-nav-group.open .mobile-nav-accordion-header i.fa-chevron-down {
    transform: rotate(180deg);
}

.mobile-nav-accordion-body {
    display: none;
    padding: 0.35rem 0.35rem 0.45rem 0.35rem;
    background: rgba(0, 0, 0, 0.2);
    flex-direction: column;
    gap: 0.25rem;
    flex-shrink: 0;
    box-sizing: border-box;
}

.mobile-nav-group.open .mobile-nav-accordion-body {
    display: flex;
}

.mobile-sub-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.65rem;
    color: rgba(245, 238, 223, 0.88);
    text-decoration: none !important;
    font-size: 0.85rem;
    font-family: var(--font-secondary);
    font-weight: 600;
    line-height: 1.2;
    border-radius: var(--border-radius);
    border-left: 3px solid transparent !important;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    margin: 0;
    box-sizing: border-box;
    width: 100%;
    flex-shrink: 0;
    min-height: 38px;
}

.mobile-sub-item > i {
    width: 1.25rem;
    min-width: 1.25rem;
    text-align: center;
    font-size: 0.92rem;
    opacity: 0.85;
    flex-shrink: 0;
}

.mobile-sub-item > span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.mobile-sub-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    text-decoration: none !important;
}

.mobile-sub-item.active {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    border-left: 3px solid var(--line-rabat) !important;
    font-weight: 700;
    text-decoration: none !important;
}

.mobile-sub-item.active > i {
    opacity: 1;
    color: var(--line-rabat);
}

.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(45, 42, 38, 0.7);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

body.nav-open .mobile-nav-drawer {
    right: 0;
    box-shadow: calc(var(--shadow-offset) * -2) 0 20px rgba(0, 0, 0, 0.5);
}

body.nav-open .mobile-nav-overlay {
    opacity: 1;
    pointer-events: auto;
}

body.nav-open {
    overflow: hidden;
    /* Prevent scrolling when menu is open */
}

/* === Responsive Rules === */
@media (min-width: 1151px) and (max-width: 1320px) {
    .nav-menu {
        gap: 0.5rem;
    }

    .nav-item {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 1150px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-menu-btn {
        display: block;
    }

    .app-header {
        padding: 0 1rem;
    }

    .main-content {
        padding: 5.5rem 1rem 1.5rem 1rem;
    }

    .card {
        padding: 1rem !important;
    }

    .card.p-0 {
        padding: 0 !important;
    }
}

/* === Cards === */
.card {
    background: var(--bg-panel);
    border: var(--border-width) solid var(--line);
    padding: 2rem;
    box-shadow: var(--box-shadow);
    border-radius: var(--border-radius);
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.card-title {
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    color: var(--ink);
    border-bottom: var(--border-width) dashed var(--line);
    padding-bottom: 0.5rem;
    text-transform: uppercase;
}

/* === Forms === */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 0.9rem;
    color: var(--ink-soft);
    margin-bottom: 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
}

.dropdown-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-item:hover,
.dropdown-item.dropdown-active {
    background: rgba(0, 0, 0, 0.05);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-secondary);
    font-size: 1rem;
    background-color: var(--bg-color);
    border: var(--border-width) solid var(--line);
    color: var(--ink);
    transition: all 0.2s;
    border-radius: var(--border-radius);
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    accent-color: var(--accent);
    cursor: pointer;
}

input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-offset) var(--shadow-offset) 0px rgba(156, 74, 26, 0.2);
}

/* === Buttons === */
.btn {
    font-family: var(--font-secondary);
    padding: 1rem 2rem;
    border: var(--border-width) solid var(--ink);
    border-radius: var(--border-radius);
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.9rem;
    transition: all 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    box-shadow: calc(var(--shadow-offset) * 0.75) calc(var(--shadow-offset) * 0.75) 0px var(--ink);
}

.btn:active {
    transform: translate(3px, 3px);
    box-shadow: 0px 0px 0px var(--ink);
}

.btn-primary {
    background-color: var(--accent);
    color: var(--bg-panel);
    border-color: var(--ink);
}

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

.btn-danger {
    background-color: var(--danger);
    color: var(--bg-panel);
    border-color: var(--ink);
}

.btn-secondary {
    background-color: var(--bg-color);
    color: var(--ink);
}

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

/* === Grids & Utilities === */
.grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 2rem;
}

.col-1 {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .md-col-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .md-col-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

.mb-4 {
    margin-bottom: 1.5rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.flex-wrap {
    flex-wrap: wrap;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* === Toast Notifications === */
#toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--ink);
    color: var(--bg-panel);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-family: var(--font-secondary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 4px solid var(--accent);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.toast-success {
    border-left-color: var(--ok);
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-info {
    border-left-color: var(--brand-green-light);
}

/* Dialog Modals Styling */
dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    background: var(--bg-panel);
    width: 90vw;
    max-width: 650px;
    max-height: 85vh;
    max-height: 85dvh;
    padding: 0;
}

dialog:not([open]) {
    display: none !important;
}

dialog[open] {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

/* Modal Footer & Action Button Standardized Layout */
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--line);
    background: var(--bg-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .modal-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-footer .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

@media (max-width: 360px) {
    .app-header {
        padding: 0 0.5rem !important;
    }

    .main-content {
        padding-top: 4.0rem !important;
    }

    .brand-logo-text {
        padding-left: 10px !important;
    }

    .app-header .brand-logo-text {
        margin-left: calc(var(--logo-height) + 8px) !important;
    }

    .brand-logo-line1 {
        font-size: 1.35rem !important;
        letter-spacing: 0.35em !important;
    }

    .brand-logo-line2 {
        font-size: 0.82rem !important;
        letter-spacing: 0.5px !important;
    }

    .mobile-menu-btn {
        padding: 0.25rem !important;
    }
}