/* ==========================================================================
   OKE Modern Layout - Sidebar + Header + Content Area
   ========================================================================== */

/* ==========================================================================
   App Shell
   ========================================================================== */
.oke-app {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.oke-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--oke-sidebar-width);
    height: 100vh;
    background: var(--oke-bg-sidebar);
    z-index: var(--oke-z-sidebar);
    display: flex;
    flex-direction: column;
    transition: width var(--oke-transition-sidebar), transform var(--oke-transition-sidebar);
    box-shadow: var(--oke-shadow-sidebar);
    overflow: hidden;
}

.oke-sidebar.collapsed {
    width: var(--oke-sidebar-collapsed);
}

/* Sidebar Brand/Logo */
.oke-sidebar__brand {
    display: flex;
    align-items: center;
    padding: var(--oke-space-5) var(--oke-space-5);
    height: var(--oke-header-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.oke-sidebar__brand-logo {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--oke-radius-lg);
    object-fit: contain;
}

.oke-sidebar__brand-text {
    margin-left: var(--oke-space-3);
    font-size: var(--oke-text-lg);
    font-weight: var(--oke-font-bold);
    color: #FFFFFF;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--oke-transition-base);
}

.oke-sidebar.collapsed .oke-sidebar__brand-text {
    opacity: 0;
    pointer-events: none;
}

/* Sidebar Navigation */
.oke-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--oke-space-4) var(--oke-space-3);
}

.oke-sidebar__nav::-webkit-scrollbar {
    width: 3px;
}
.oke-sidebar__nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--oke-radius-full);
}

/* Sidebar Section */
.oke-sidebar__section {
    margin-bottom: var(--oke-space-6);
}

.oke-sidebar__section-title {
    font-size: var(--oke-text-xs);
    font-weight: var(--oke-font-semibold);
    color: var(--oke-text-sidebar-heading);
    text-transform: uppercase;
    letter-spacing: var(--oke-tracking-widest);
    padding: var(--oke-space-2) var(--oke-space-3);
    margin-bottom: var(--oke-space-1);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--oke-transition-base);
}

.oke-sidebar.collapsed .oke-sidebar__section-title {
    opacity: 0;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Sidebar Menu Items */
.oke-sidebar__item {
    display: flex;
    align-items: center;
    padding: var(--oke-space-2) var(--oke-space-3);
    margin-bottom: 2px;
    border-radius: var(--oke-radius-md);
    color: var(--oke-text-sidebar);
    font-size: var(--oke-text-sm);
    font-weight: var(--oke-font-medium);
    cursor: pointer;
    transition: all var(--oke-transition-fast);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.oke-sidebar__item:hover {
    background: var(--oke-bg-sidebar-hover);
    color: var(--oke-text-sidebar-active);
    text-decoration: none;
}

.oke-sidebar__item.active {
    background: var(--oke-bg-sidebar-active);
    color: var(--oke-text-sidebar-active);
    font-weight: var(--oke-font-semibold);
}

.oke-sidebar__item-icon {
    width: 20px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--oke-text-base);
    margin-right: var(--oke-space-3);
    opacity: 0.8;
    transition: opacity var(--oke-transition-fast);
}

.oke-sidebar__item:hover .oke-sidebar__item-icon,
.oke-sidebar__item.active .oke-sidebar__item-icon {
    opacity: 1;
}

.oke-sidebar__item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--oke-transition-base);
}

.oke-sidebar.collapsed .oke-sidebar__item-text {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.oke-sidebar.collapsed .oke-sidebar__item {
    justify-content: center;
    padding: var(--oke-space-3) var(--oke-space-2);
}

.oke-sidebar.collapsed .oke-sidebar__item-icon {
    margin-right: 0;
    font-size: var(--oke-text-md);
}

/* Sidebar Submenu (dropdown) */
.oke-sidebar__submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--oke-transition-slow);
    padding-left: var(--oke-space-8);
}

.oke-sidebar__submenu.open {
    max-height: 500px;
}

.oke-sidebar__submenu .oke-sidebar__item {
    font-size: var(--oke-text-xs);
    padding: 6px var(--oke-space-3);
}

.oke-sidebar__item-arrow {
    margin-left: auto;
    font-size: var(--oke-text-xs);
    transition: transform var(--oke-transition-base);
    opacity: 0.5;
}

.oke-sidebar__item.expanded .oke-sidebar__item-arrow {
    transform: rotate(90deg);
}

.oke-sidebar.collapsed .oke-sidebar__item-arrow {
    display: none;
}

.oke-sidebar.collapsed .oke-sidebar__submenu {
    display: none;
}

/* Sidebar Footer */
.oke-sidebar__footer {
    padding: var(--oke-space-4) var(--oke-space-3);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

/* Collapsed Tooltip */
.oke-sidebar.collapsed .oke-sidebar__item[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--oke-sidebar-collapsed) + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--oke-bg-sidebar);
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--oke-radius-md);
    font-size: var(--oke-text-xs);
    white-space: nowrap;
    z-index: 9999;
    box-shadow: var(--oke-shadow-lg);
    pointer-events: none;
}

/* ==========================================================================
   Header / Top Bar
   ========================================================================== */
.oke-header {
    position: fixed;
    top: 0;
    left: var(--oke-sidebar-width);
    right: 0;
    height: var(--oke-header-height);
    background: var(--oke-bg-header);
    border-bottom: 1px solid var(--oke-border);
    display: flex;
    align-items: center;
    padding: 0 var(--oke-space-6);
    z-index: var(--oke-z-header);
    box-shadow: var(--oke-shadow-header);
    transition: left var(--oke-transition-sidebar), background-color var(--oke-transition-slow);
}

body.sidebar-collapsed .oke-header {
    left: var(--oke-sidebar-collapsed);
}

/* Header Toggle Button */
.oke-header__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--oke-text-secondary);
    border-radius: var(--oke-radius-md);
    cursor: pointer;
    transition: all var(--oke-transition-fast);
    margin-right: var(--oke-space-4);
    font-size: var(--oke-text-lg);
}

.oke-header__toggle:hover {
    background: var(--oke-bg-surface-secondary);
    color: var(--oke-text-primary);
}

/* Header Breadcrumb */
.oke-header__breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--oke-space-2);
    font-size: var(--oke-text-sm);
    color: var(--oke-text-tertiary);
    flex: 1;
}

.oke-header__breadcrumb a {
    color: var(--oke-text-tertiary);
    transition: color var(--oke-transition-fast);
}

.oke-header__breadcrumb a:hover {
    color: var(--oke-text-primary);
}

.oke-header__breadcrumb-separator {
    font-size: var(--oke-text-xs);
    opacity: 0.5;
}

.oke-header__breadcrumb-current {
    color: var(--oke-text-primary);
    font-weight: var(--oke-font-medium);
}

/* Header Search */
.oke-header__search {
    position: relative;
    max-width: 320px;
    flex: 1;
    margin: 0 var(--oke-space-4);
}

.oke-header__search input {
    width: 100%;
    height: 38px;
    padding: 0 var(--oke-space-4) 0 38px;
    border: 1px solid var(--oke-border);
    border-radius: var(--oke-radius-full);
    background: var(--oke-bg-surface-secondary);
    color: var(--oke-text-primary);
    font-size: var(--oke-text-sm);
    font-family: var(--oke-font-primary);
    transition: all var(--oke-transition-fast);
    outline: none;
}

.oke-header__search input:focus {
    border-color: var(--oke-border-focus);
    box-shadow: var(--oke-shadow-focus);
    background: var(--oke-bg-surface);
}

.oke-header__search input::placeholder {
    color: var(--oke-text-tertiary);
}

.oke-header__search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--oke-text-tertiary);
    font-size: var(--oke-text-sm);
    pointer-events: none;
}

/* Header Actions */
.oke-header__actions {
    display: flex;
    align-items: center;
    gap: var(--oke-space-2);
}

.oke-header__action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--oke-text-secondary);
    border-radius: var(--oke-radius-md);
    cursor: pointer;
    transition: all var(--oke-transition-fast);
    position: relative;
    font-size: var(--oke-text-md);
}

.oke-header__action-btn:hover {
    background: var(--oke-bg-surface-secondary);
    color: var(--oke-text-primary);
}

.oke-header__action-btn .badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--oke-danger);
    border-radius: var(--oke-radius-full);
    border: 2px solid var(--oke-bg-header);
}

/* Theme Toggle */
.oke-theme-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none !important;
    background: var(--oke-bg-surface-secondary) !important;
    color: var(--oke-text-secondary) !important;
    border-radius: var(--oke-radius-md) !important;
    cursor: pointer;
    transition: all var(--oke-transition-fast);
    font-size: var(--oke-text-md);
}

.oke-theme-toggle:hover {
    background: var(--oke-bg-surface-secondary);
    color: var(--oke-warning);
}

/* Header User Menu */
.oke-header__user {
    display: flex;
    align-items: center;
    gap: var(--oke-space-3);
    margin-left: var(--oke-space-4);
    padding-left: var(--oke-space-4);
    border-left: 1px solid var(--oke-border);
    cursor: pointer;
    position: relative;
}

.oke-header__user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--oke-radius-full);
    object-fit: cover;
    border: 2px solid var(--oke-border);
    transition: border-color var(--oke-transition-fast);
}

.oke-header__user:hover .oke-header__user-avatar {
    border-color: var(--oke-primary);
}

.oke-header__user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.oke-header__user-name {
    font-size: var(--oke-text-sm);
    font-weight: var(--oke-font-semibold);
    color: var(--oke-text-primary);
}

.oke-header__user-role {
    font-size: var(--oke-text-xs);
    color: var(--oke-text-tertiary);
}

/* Header User Dropdown */
.oke-header__user-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 280px;
    background: var(--oke-bg-card);
    border: 1px solid var(--oke-border);
    border-radius: var(--oke-radius-lg);
    box-shadow: var(--oke-shadow-xl);
    z-index: var(--oke-z-modal);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--oke-transition-base);
    padding: var(--oke-space-2);
}

.oke-header__user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.oke-header__user-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--oke-space-3);
    padding: var(--oke-space-3) var(--oke-space-3);
    border-radius: var(--oke-radius-md);
    color: var(--oke-text-secondary);
    font-size: var(--oke-text-sm);
    cursor: pointer;
    transition: all var(--oke-transition-fast);
    text-decoration: none;
}

.oke-header__user-dropdown-item:hover {
    background: var(--oke-bg-surface-secondary);
    color: var(--oke-text-primary);
    text-decoration: none;
}

.oke-header__user-dropdown-item.danger {
    color: var(--oke-danger);
}

.oke-header__user-dropdown-item.danger:hover {
    background: var(--oke-danger-light);
    color: var(--oke-danger-dark);
}

.oke-header__user-dropdown-divider {
    height: 1px;
    background: var(--oke-border);
    margin: var(--oke-space-2) 0;
}

.oke-header__user-dropdown-header {
    padding: var(--oke-space-3);
    border-bottom: 1px solid var(--oke-border);
    margin-bottom: var(--oke-space-2);
}

.oke-header__user-dropdown-header strong {
    display: block;
    font-size: var(--oke-text-sm);
    color: var(--oke-text-primary);
}

.oke-header__user-dropdown-header small {
    font-size: var(--oke-text-xs);
    color: var(--oke-text-tertiary);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.oke-content {
    margin-left: var(--oke-sidebar-width);
    margin-top: var(--oke-header-height);
    min-height: calc(100vh - var(--oke-header-height));
    padding: var(--oke-space-6);
    transition: margin-left var(--oke-transition-sidebar);
    width: calc(100% - var(--oke-sidebar-width));
}

body.sidebar-collapsed .oke-content {
    margin-left: var(--oke-sidebar-collapsed);
    width: calc(100% - var(--oke-sidebar-collapsed));
}

/* Page Header */
.oke-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--oke-space-6);
    flex-wrap: wrap;
    gap: var(--oke-space-4);
}

.oke-page-header__title {
    font-size: var(--oke-text-2xl);
    font-weight: var(--oke-font-bold);
    color: var(--oke-text-primary);
    margin: 0;
}

.oke-page-header__subtitle {
    font-size: var(--oke-text-sm);
    color: var(--oke-text-tertiary);
    margin: var(--oke-space-1) 0 0 0;
}

.oke-page-header__actions {
    display: flex;
    align-items: center;
    gap: var(--oke-space-3);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.oke-footer {
    margin-left: var(--oke-sidebar-width);
    padding: var(--oke-space-4) var(--oke-space-6);
    border-top: 1px solid var(--oke-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--oke-text-xs);
    color: var(--oke-text-tertiary);
    transition: margin-left var(--oke-transition-sidebar);
}

body.sidebar-collapsed .oke-footer {
    margin-left: var(--oke-sidebar-collapsed);
}

/* ==========================================================================
   Overlay for mobile sidebar
   ========================================================================== */
.oke-sidebar-overlay {
    display: none !important;
    pointer-events: none !important;
}

/* ==========================================================================
   Loading Overlay (replaces paredeBranca)
   ========================================================================== */
.oke-loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--oke-bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1045; /* Abaixo do .modal-backdrop (1050) e .modal (1055) para não bloquear modais */
    opacity: 0;
    visibility: hidden;
    transition: all var(--oke-transition-base);
    backdrop-filter: blur(4px);
}

.oke-loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.oke-loading-overlay__content {
    background: var(--oke-bg-card);
    border-radius: var(--oke-radius-xl);
    padding: var(--oke-space-8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--oke-space-4);
    box-shadow: var(--oke-shadow-xl);
    animation: fadeInUp 0.3s ease-out;
}

.oke-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--oke-border);
    border-top-color: var(--oke-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.oke-loading-overlay__text {
    font-size: var(--oke-text-sm);
    color: var(--oke-text-secondary);
    font-weight: var(--oke-font-medium);
}

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   WEBCLIENT Portal Layout (wc-*)
   ========================================================================== */

/* Header */
.wc-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--oke-bg-header);
    border-bottom: 1px solid var(--oke-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--oke-space-6);
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

[data-theme="dark"] .wc-header {
    background: rgba(31, 41, 55, 0.92);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.wc-header__left {
    display: flex;
    align-items: center;
}

.wc-header__brand {
    display: flex;
    align-items: center;
    gap: var(--oke-space-3);
    text-decoration: none;
    color: var(--oke-text-primary);
    transition: opacity 0.2s ease;
}

.wc-header__brand:hover {
    opacity: 0.85;
    text-decoration: none;
    color: var(--oke-text-primary);
}

.wc-header__logo-wrap {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: var(--oke-radius-lg);
    background: #007BFF;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(var(--oke-primary-rgb), 0.25);
}

.wc-header__logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.wc-header__brand-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.wc-header__brand-name {
    font-size: var(--oke-text-md);
    font-weight: var(--oke-font-bold);
    color: var(--oke-text-primary);
    letter-spacing: -0.01em;
}

.wc-header__brand-sub {
    font-size: 11px;
    color: var(--oke-text-tertiary);
    font-weight: var(--oke-font-normal);
}

.wc-header__right {
    display: flex;
    align-items: center;
    gap: var(--oke-space-3);
}

.wc-header__divider {
    width: 1px;
    height: 24px;
    background: var(--oke-border);
}

.wc-header__logout {
    display: flex;
    align-items: center;
    gap: var(--oke-space-2);
    padding: var(--oke-space-2) var(--oke-space-4);
    border-radius: var(--oke-radius-md);
    color: var(--oke-danger);
    font-size: var(--oke-text-sm);
    font-weight: var(--oke-font-medium);
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.wc-header__logout:hover {
    background: var(--oke-danger-light);
    color: var(--oke-danger-dark);
    text-decoration: none;
    border-color: rgba(239, 68, 68, 0.15);
}

/* Body wrapper */
.wc-body {
    padding-top: 64px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Content area */
.wc-content {
    flex: 1;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: var(--oke-space-8) var(--oke-space-6);
}

.wc-content .container,
.wc-content .container-sm,
.wc-content .container-md,
.wc-content .container-lg,
.wc-content .container-xl,
.wc-content .container-xxl {
    width: 100% !important;
    max-width: none !important;
}

/* Footer */
.wc-footer {
    padding: var(--oke-space-5) var(--oke-space-6);
    border-top: 1px solid var(--oke-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--oke-text-xs);
    color: var(--oke-text-tertiary);
    width: 100%;
    max-width: none;
    margin: 0;
}

.wc-footer__brand img {
    height: 22px;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.wc-footer__brand:hover img {
    opacity: 0.8;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 1024px) {
    .oke-sidebar {
        transform: translateX(-100%);
    }

    .oke-sidebar.mobile-open {
        transform: translateX(0);
    }

    .oke-sidebar-overlay {
        display: none !important;
        pointer-events: none !important;
    }

    .oke-header {
        left: 0;
    }

    .oke-content {
        margin-left: 0;
        width: 100%;
    }

    .oke-footer {
        margin-left: 0;
    }

    body.sidebar-collapsed .oke-header,
    body.sidebar-collapsed .oke-content,
    body.sidebar-collapsed .oke-footer {
        margin-left: 0;
        left: 0;
    }

    .oke-header__search {
        display: none;
    }

    .oke-header__user-info {
        display: none;
    }
}

@media (max-width: 768px) {
    .oke-content {
        padding: var(--oke-space-4);
    }

    .oke-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .oke-header__breadcrumb {
        display: none;
    }

    /* Webclient responsive */
    .wc-header {
        padding: 0 var(--oke-space-4);
    }

    .wc-header__brand-sub {
        display: none;
    }

    .wc-header__logout span {
        display: none;
    }

    .wc-content {
        padding: var(--oke-space-5) var(--oke-space-4);
    }
}
