/* ═══════════════════════════════════════════════════
   ROD Portal – Demo Management Styles
   Replicates the real app sidebar/topbar/layout
   ═══════════════════════════════════════════════════ */

:root {
    --theme-primary: #198754;
    --theme-primary-dark: #146c43;
    --theme-primary-rgb: 25, 135, 84;
    --sidebar-width: 68px;
    --topbar-height: 52px;
    --surface-card: #fff;
    --surface-border: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #6c757d;
}

[data-bs-theme="dark"] {
    --surface-card: #1e1e2e;
    --surface-border: #3a3a4a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: #f8f9fa;
}
[data-bs-theme="dark"] body { background: #121212; }

/* ── Sidebar ───────────────────────────────────────── */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--theme-primary-dark) 0%, var(--theme-primary) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1050;
    padding: 8px 0;
    box-shadow: 2px 0 12px rgba(0,0,0,.15);
    transition: transform 0.3s ease;
}

.sidebar-logo {
    width: 100%;
    text-align: center;
    padding: 10px 0 14px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    margin-bottom: 8px;
}

.sidebar-logo-fallback {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    color: #fff;
    font-size: 1.1rem;
}

.sidebar-nav-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
    padding: 0 8px;
}

.sidebar-nav-spacer { flex: 1; }

.sidebar-nav-item {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    font-size: 1.05rem;
    transition: all 0.2s;
    position: relative;
}
.sidebar-nav-item:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
}
.sidebar-nav-item.active {
    background: rgba(255,255,255,.25);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

/* ── Flyout Submenus ───────────────────────────────── */
.sidebar-flyout-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
}

.sidebar-flyout {
    position: absolute;
    left: calc(var(--sidebar-width) - 8px);
    top: 0;
    min-width: 220px;
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    padding: 10px 0;
    display: none;
    z-index: 1060;
}
.sidebar-flyout-wrapper:hover .sidebar-flyout { display: block; }

.sidebar-flyout-title {
    padding: 4px 16px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.sidebar-flyout-divider {
    margin: 2px 0;
    border: 0;
    border-top: 1px solid var(--surface-border);
    opacity: .8;
}

.sidebar-flyout-item {
    display: block;
    padding: 8px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.88rem;
    transition: background 0.15s;
}
.sidebar-flyout-item:hover { background: rgba(var(--theme-primary-rgb), .08); color: var(--theme-primary); }
.sidebar-flyout-item.active { color: var(--theme-primary); font-weight: 600; }
.sidebar-flyout-item i { width: 20px; margin-right: 6px; }

/* ── Top Bar ───────────────────────────────────────── */
.app-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--surface-card);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1040;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-separator { width: 1px; height: 24px; background: var(--surface-border); }
.topbar-page-title { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); }

.topbar-icon-btn, .topbar-lang-btn, .topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.88rem;
    transition: background 0.15s;
}
.topbar-icon-btn:hover, .topbar-lang-btn:hover, .topbar-user-btn:hover {
    background: rgba(var(--theme-primary-rgb), .08);
    color: var(--theme-primary);
}
.topbar-username { font-weight: 500; }

.topbar-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #dc3545;
    color: #fff;
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 10px;
    font-weight: 700;
}
.topbar-dropdown { position: relative; }

.dark-mode-toggle {
    font-size: 1rem;
    transition: transform 0.4s;
}
.dark-mode-toggle:hover { transform: rotate(30deg); }

/* ── Main Content ──────────────────────────────────── */
.app-main {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height) !important; /* beats Bootstrap mt-3 !important via load order */
    width: calc(100% - var(--sidebar-width));    /* fix container-fluid width:100% + margin overflow */
    box-sizing: border-box;
    padding: 20px;
    min-height: calc(100vh - var(--topbar-height) - 60px);
}

.app-footer {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    box-sizing: border-box;
    font-size: 0.85rem;
}

/* ── Garden Map ────────────────────────────────────── */
.garden-map-isles {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-x: auto;
    padding: 8px 0;
}

.isle-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.isle-label {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 2px 0;
    background: rgba(var(--theme-primary-rgb), .06);
    border-radius: 4px;
}

.isle-row {
    display: flex;
    gap: 3px;
    flex-wrap: nowrap;
}

.allotment-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    height: 52px;
    border-radius: 6px;
    font-size: 0.78rem;
    text-decoration: none;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    text-align: center;
    line-height: 1.2;
}
.allotment-tile:hover { transform: scale(1.08); box-shadow: 0 3px 10px rgba(0,0,0,.2); color: #fff; z-index: 2; }
.allotment-tile strong { font-size: 0.85rem; }
.allotment-tile small { font-size: 0.6rem; opacity: 0.85; }

.allotment-green { background: #198754; }
.allotment-yellow { background: #ffc107; color: #333; }
.allotment-yellow:hover { color: #333; }
.allotment-red { background: #dc3545; }
.allotment-grey { background: #6c757d; }

/* ── Clickable Rows ────────────────────────────────── */
.clickable-row { cursor: pointer; }
.clickable-row:hover { background-color: rgba(var(--theme-primary-rgb), .05) !important; }

/* ── Cards ─────────────────────────────────────────── */
.card {
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.card-header {
    background: rgba(var(--theme-primary-rgb), .04);
    border-bottom: 1px solid var(--surface-border);
    padding: 12px 16px;
}

/* ── Demo Banner ───────────────────────────────────── */
.demo-banner {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
    padding: 10px 20px;
    font-size: 0.85rem;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 -3px 12px rgba(0,0,0,.2);
    border-top: 3px solid var(--theme-primary);
}

/* ── Mobile ────────────────────────────────────────── */
.sidebar-mobile-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: var(--theme-primary);
    color: #fff;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1060;
}
.sidebar-mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-hamburger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.sidebar-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1045;
}

@media (max-width: 991.98px) {
    .sidebar-mobile-topbar { display: flex; }
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .app-topbar { left: 0; top: 52px; }
    .app-main {
        margin-left: 0;
        margin-top: calc(52px + var(--topbar-height)) !important;
        width: 100%;
    }
    .app-footer { margin-left: 0; width: 100%; }
    .demo-banner { left: 0; }
}

@media (max-width: 575.98px) {
    .app-main { padding: 12px; }
    .allotment-tile { min-width: 48px; height: 42px; font-size: 0.7rem; }
    .allotment-tile strong { font-size: 0.75rem; }
    .allotment-tile small { display: none; }
}

/* ── Table Dark Header with theme ──────────────────── */
.table-dark th {
    background: var(--theme-primary) !important;
    border-color: var(--theme-primary-dark) !important;
}

/* ── Button Success with theme ─────────────────────── */
.btn-success {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}
.btn-success:hover {
    background-color: var(--theme-primary-dark) !important;
    border-color: var(--theme-primary-dark) !important;
}

/* ── Page bottom padding for demo banner ───────────── */
body { padding-bottom: 50px; }

/* ── Nav tabs theme ────────────────────────────────── */
.nav-tabs .nav-link.active {
    color: var(--theme-primary);
    border-bottom-color: var(--theme-primary);
}
.nav-tabs .nav-link:hover {
    color: var(--theme-primary);
}
