/* ============================================
   CEDAR Site Styles
   ============================================ */

/* Base font sizes */
html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

/* Focus styles */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* Form floating placeholder styles */
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--cedar-primary, #0066B3);
    color: white;
    padding: 0.75rem 1.5rem;
    z-index: 9999;
    text-decoration: none;
    font-weight: 500;
    border-radius: 0 0 0.5rem 0;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    color: white;
    outline: 2px solid white;
    outline-offset: 2px;
}

/* ============================================
   CSS Variables for Layout
   ============================================ */
:root {
    --cedar-sidebar-width: 260px;
    --cedar-sidebar-collapsed-width: 0px;
    --cedar-header-height: 60px;
    --cedar-footer-height: 50px;
    --cedar-sidebar-bg: #1e293b;
    --cedar-sidebar-text: #94a3b8;
    --cedar-sidebar-text-hover: #ffffff;
    --cedar-sidebar-active-bg: rgba(59, 130, 246, 0.2);
    --cedar-sidebar-active-border: #3b82f6;
    --cedar-header-bg: #ffffff;
    --cedar-content-bg: #f1f5f9;
}

/* ============================================
   Unauthenticated Layout (Simple)
   ============================================ */
.cedar-simple-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.cedar-simple-content {
    flex: 1;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.cedar-simple-wrapper > footer {
    margin-top: auto;
}

/* ============================================
   Authenticated Layout (Sidebar + Header)
   ============================================ */
.authenticated-layout {
    overflow-x: hidden;
}

.cedar-app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ============================================
   Sidebar Styles
   ============================================ */
.cedar-sidebar {
    width: var(--cedar-sidebar-width);
    background-color: var(--cedar-sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar Header */
.cedar-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: var(--cedar-header-height);
}

.cedar-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #ffffff;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 700;
}

.cedar-sidebar-brand i {
    color: var(--cedar-primary, #0066B3);
    font-size: 1.75rem;
}

.cedar-sidebar-brand:hover {
    color: #ffffff;
    text-decoration: none;
}

.cedar-sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--cedar-sidebar-text);
    font-size: 1.25rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.cedar-sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Sidebar Navigation */
.cedar-sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.cedar-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Collapsible Menu Section */
.cedar-nav-section {
    margin-bottom: 0.25rem;
    list-style: none;
}

.cedar-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--cedar-sidebar-text);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.875rem 1.25rem 0.5rem;
    margin-top: 0.5rem;
    cursor: pointer;
    transition: color 0.2s ease;
    user-select: none;
}

.cedar-nav-header:hover {
    color: var(--cedar-sidebar-text-hover);
}

.cedar-nav-header .cedar-nav-toggle {
    font-size: 0.65rem;
    transition: transform 0.3s ease;
}

.cedar-nav-header[aria-expanded="false"] .cedar-nav-toggle {
    transform: rotate(-90deg);
}

.cedar-nav-section-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cedar-nav-section-items.collapse:not(.show) {
    display: none;
}

.cedar-nav-section-items.collapsing {
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease;
}

.cedar-nav-item {
    margin: 0.125rem 0.75rem;
}

.cedar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    color: var(--cedar-sidebar-text);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
}

.cedar-nav-link i {
    font-size: 1.125rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.cedar-nav-link:hover {
    color: var(--cedar-sidebar-text-hover);
    background-color: rgba(255, 255, 255, 0.05);
}

.cedar-nav-link.active {
    color: var(--cedar-sidebar-text-hover);
    background-color: var(--cedar-sidebar-active-bg);
    border-left-color: var(--cedar-sidebar-active-border);
}

/* ============================================
   Main Content Wrapper
   ============================================ */
.cedar-main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--cedar-sidebar-width);
    background-color: var(--cedar-content-bg);
    transition: margin-left 0.3s ease;
}

/* ============================================
   Top Header
   ============================================ */
.cedar-top-header {
    background-color: var(--cedar-header-bg);
    border-bottom: 1px solid #e2e8f0;
    height: var(--cedar-header-height);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.cedar-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1.5rem;
}

.cedar-header-title {
    color: #475569;
    font-size: 0.9375rem;
}

.cedar-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cedar-header-actions .nav {
    flex-wrap: nowrap;
}

.cedar-header-actions .nav-link {
    padding: 0.5rem 0.75rem;
    color: #475569;
}

.cedar-header-actions .nav-link:hover {
    color: var(--cedar-primary, #0066B3);
}

/* ============================================
   Main Content Area
   ============================================ */
.cedar-content {
    flex: 1;
    padding: 1.5rem;
}

.cedar-content-inner {
    max-width: 100%;
}

/* ============================================
   Footer (Sticky)
   ============================================ */
.cedar-footer {
    background-color: var(--cedar-header-bg);
    border-top: 1px solid #e2e8f0;
    padding: 0.875rem 1.5rem;
    margin-top: auto;
}

.cedar-footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #64748b;
}

/* ============================================
   Sidebar Overlay (Mobile)
   ============================================ */
.cedar-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cedar-sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Responsive Styles
   ============================================ */

/* Large screens and up - sidebar always visible */
@media (min-width: 992px) {
    .cedar-sidebar {
        transform: translateX(0);
    }

    .cedar-sidebar-toggle {
        display: none;
    }
}

/* Medium and below - sidebar hidden by default */
@media (max-width: 991.98px) {
    .cedar-sidebar {
        transform: translateX(-100%);
    }

    .cedar-sidebar.show {
        transform: translateX(0);
    }

    .cedar-main-wrapper {
        margin-left: 0;
    }

    .cedar-header-content {
        padding: 0 1rem;
    }

    .cedar-content {
        padding: 1rem;
    }

    .cedar-footer {
        padding: 0.75rem 1rem;
    }

    .cedar-footer-content {
        flex-direction: column;
        text-align: center;
    }
}

/* Small screens */
@media (max-width: 575.98px) {
    .cedar-sidebar-brand span {
        font-size: 1.25rem;
    }

    .cedar-nav-link {
        padding: 0.75rem;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .cedar-sidebar,
    .cedar-top-header,
    .cedar-footer,
    .cedar-sidebar-overlay {
        display: none !important;
    }

    .cedar-main-wrapper {
        margin-left: 0 !important;
    }

    .cedar-content {
        padding: 0 !important;
    }
}

/* ============================================
   Scrollbar Styles for Sidebar
   ============================================ */
.cedar-sidebar::-webkit-scrollbar {
    width: 6px;
}

.cedar-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.cedar-sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.cedar-sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Firefox scrollbar */
.cedar-sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* ============================================
   Body state when sidebar is open on mobile
   ============================================ */
body.sidebar-open {
    overflow: hidden;
}

/* ============================================
   Navigation active state improvements
   ============================================ */
.cedar-nav-link.active i {
    color: var(--cedar-sidebar-active-border);
}
