/* ============================================
   OnePlatform Layout System
   Sidebar + Topbar + Content Layout
   ============================================ */

/* ============================================
   Main Layout Container
   ============================================ */

.op-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--op-bg-page);
}

.op-layout.sidebar-collapsed .op-sidebar {
    width: var(--op-sidebar-collapsed-width);
}

.op-layout.sidebar-collapsed .op-sidebar-brand-name,
.op-layout.sidebar-collapsed .op-sidebar-nav-text,
.op-layout.sidebar-collapsed .op-sidebar-section-title,
.op-layout.sidebar-collapsed .op-sidebar-footer-details,
.op-layout.sidebar-collapsed .op-nav-arrow {
    opacity: 0;
    visibility: hidden;
    width: 0;
}

.op-layout.sidebar-collapsed .op-main {
    margin-left: var(--op-sidebar-collapsed-width);
}

.op-layout.sidebar-collapsed .op-sidebar-nav-item {
    justify-content: center;
    padding: var(--op-space-3);
}

.op-layout.sidebar-collapsed .op-sidebar-nav-icon {
    margin-right: 0;
}

/* ============================================
   Sidebar
   ============================================ */

.op-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--op-sidebar-width);
    background-color: var(--op-bg-sidebar);
    border-right: 1px solid var(--op-border);
    display: flex;
    flex-direction: column;
    z-index: var(--op-z-fixed);
    transition: width var(--op-transition-smooth);
    overflow: hidden;
}

/* Sidebar Header */
.op-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--op-space-4) var(--op-space-4);
    height: var(--op-topbar-height);
    border-bottom: 1px solid var(--op-border-light);
    flex-shrink: 0;
}

.op-sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--op-space-3);
    text-decoration: none;
}

.op-sidebar-brand-logo {
    width: 150px;
    height: auto;
    max-height: 60px;
    border-radius: var(--op-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--op-text-inverse);
    flex-shrink: 0;
    object-fit: contain;
}

.op-sidebar-brand-logo img,
.op-sidebar-brand-logo svg,
.brand-logo-img {
    width: 150px;
    height: auto;
    max-height: 60px;
    object-fit: contain;
}

.op-sidebar-brand-name {
    font-size: var(--op-text-lg);
    font-weight: var(--op-font-bold);
    color: var(--op-text-primary);
    white-space: nowrap;
    transition: opacity var(--op-transition-fast), width var(--op-transition-fast);
}

.op-sidebar-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--op-text-secondary);
    border-radius: var(--op-radius-md);
    cursor: pointer;
    transition: all var(--op-transition-fast);
}

.op-sidebar-toggle:hover {
    background-color: var(--op-bg-hover);
    color: var(--op-text-primary);
}

/* Sidebar Navigation */
.op-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--op-space-4) 0;
}

.op-sidebar-section {
    margin-bottom: var(--op-space-4);
}

.op-sidebar-section-title {
    font-size: var(--op-text-xs);
    font-weight: var(--op-font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--op-text-tertiary);
    padding: var(--op-space-2) var(--op-space-4);
    margin-bottom: var(--op-space-1);
    white-space: nowrap;
    transition: opacity var(--op-transition-fast);
}

.op-sidebar-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.op-sidebar-nav-item {
    display: flex;
    align-items: center;
    padding: var(--op-space-2) var(--op-space-4);
    margin: var(--op-space-1) var(--op-space-2);
    color: var(--op-text-secondary);
    text-decoration: none;
    border-radius: var(--op-radius-md);
    cursor: pointer;
    transition: all var(--op-transition-fast);
    position: relative;
}

.op-sidebar-nav-item:hover {
    background-color: var(--op-bg-hover);
    color: var(--op-text-primary);
}

.op-sidebar-nav-item.active {
    background-color: var(--op-primary-light);
    color: var(--op-primary);
}

.op-sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background-color: var(--op-primary);
    border-radius: 0 var(--op-radius-sm) var(--op-radius-sm) 0;
}

.op-sidebar-nav-icon {
    width: 20px;
    height: 20px;
    margin-right: var(--op-space-3);
    flex-shrink: 0;
    transition: margin var(--op-transition-fast);
}

.op-sidebar-nav-text {
    flex: 1;
    white-space: nowrap;
    font-size: var(--op-text-sm);
    font-weight: var(--op-font-medium);
    transition: opacity var(--op-transition-fast);
}

.op-nav-arrow {
    width: 16px;
    height: 16px;
    transition: transform var(--op-transition-fast), opacity var(--op-transition-fast);
}

.op-nav-arrow.expanded {
    transform: rotate(90deg);
}

/* Sub Navigation */
.op-sidebar-subnav {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--op-transition-smooth);
}

.op-sidebar-subnav.open {
    max-height: 500px;
}

.op-sidebar-subnav-item {
    display: flex;
    align-items: center;
    padding: var(--op-space-2) var(--op-space-4);
    padding-left: calc(var(--op-space-4) + 32px);
    margin: var(--op-space-1) var(--op-space-2);
    color: var(--op-text-secondary);
    text-decoration: none;
    border-radius: var(--op-radius-md);
    font-size: var(--op-text-sm);
    transition: all var(--op-transition-fast);
}

.op-sidebar-subnav-item:hover {
    background-color: var(--op-bg-hover);
    color: var(--op-text-primary);
}

.op-sidebar-subnav-item.active {
    color: var(--op-primary);
    background-color: var(--op-primary-light);
}

/* Sidebar Footer */
.op-sidebar-footer {
    padding: var(--op-space-4);
    border-top: 1px solid var(--op-border-light);
    flex-shrink: 0;
}

.op-sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--op-space-3);
    padding: var(--op-space-2);
    border-radius: var(--op-radius-md);
    cursor: pointer;
    transition: background-color var(--op-transition-fast);
}

.op-sidebar-user:hover {
    background-color: var(--op-bg-hover);
}

.op-sidebar-footer-details {
    flex: 1;
    min-width: 0;
    transition: opacity var(--op-transition-fast);
}

.op-sidebar-user-name {
    font-size: var(--op-text-sm);
    font-weight: var(--op-font-semibold);
    color: var(--op-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.op-sidebar-user-role {
    font-size: var(--op-text-xs);
    color: var(--op-text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   Main Content Area
   ============================================ */

.op-main {
    flex: 1;
    margin-left: var(--op-sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--op-transition-smooth);
}

/* ============================================
   Top App Bar
   ============================================ */

.op-topbar {
    position: sticky;
    top: 0;
    height: var(--op-topbar-height);
    background-color: var(--op-bg-topbar);
    border-bottom: 1px solid var(--op-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--op-space-6);
    z-index: var(--op-z-sticky);
    flex-shrink: 0;
}

.op-topbar-left {
    display: flex;
    align-items: center;
    gap: var(--op-space-4);
}

.op-topbar-right {
    display: flex;
    align-items: center;
    gap: var(--op-space-2);
}

/* Mobile Menu Button */
.op-mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--op-text-secondary);
    border-radius: var(--op-radius-md);
    cursor: pointer;
}

.op-mobile-menu-btn:hover {
    background-color: var(--op-bg-hover);
    color: var(--op-text-primary);
}

/* Search Box */
.op-search-box {
    position: relative;
    width: 320px;
}

.op-search-icon {
    position: absolute;
    left: var(--op-space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--op-text-tertiary);
    pointer-events: none;
}

.op-search-input {
    width: 100%;
    padding: var(--op-space-2) var(--op-space-10);
    padding-right: var(--op-space-12);
    font-size: var(--op-text-sm);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-md);
    background-color: var(--op-bg-hover);
    color: var(--op-text-primary);
    transition: all var(--op-transition-fast);
}

.op-search-input::placeholder {
    color: var(--op-text-tertiary);
}

.op-search-input:focus {
    outline: none;
    border-color: var(--op-primary);
    background-color: var(--op-bg-surface);
    box-shadow: 0 0 0 3px rgba(var(--op-primary-rgb), 0.1);
}

.op-search-shortcut {
    position: absolute;
    right: var(--op-space-3);
    top: 50%;
    transform: translateY(-50%);
    padding: var(--op-space-1) var(--op-space-2);
    font-size: var(--op-text-xs);
    font-family: var(--op-font-mono);
    color: var(--op-text-tertiary);
    background-color: var(--op-bg-surface);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-sm);
}

/* Topbar Buttons */
.op-topbar-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--op-text-secondary);
    border-radius: var(--op-radius-md);
    cursor: pointer;
    transition: all var(--op-transition-fast);
}

.op-topbar-btn:hover {
    background-color: var(--op-bg-hover);
    color: var(--op-text-primary);
}

.op-topbar-btn svg {
    width: 20px;
    height: 20px;
}

/* Notification Badge */
.op-notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: var(--op-font-bold);
    color: var(--op-text-inverse);
    background-color: var(--op-error);
    border-radius: var(--op-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Theme Toggle */
.op-theme-toggle {
    position: relative;
}

/* Topbar User */
.op-topbar-user {
    display: flex;
    align-items: center;
    gap: var(--op-space-2);
    padding: var(--op-space-1) var(--op-space-2);
    border-radius: var(--op-radius-md);
    cursor: pointer;
    transition: background-color var(--op-transition-fast);
}

.op-topbar-user:hover {
    background-color: var(--op-bg-hover);
}

/* ============================================
   Page Content
   ============================================ */

.op-content {
    flex: 1;
    padding: var(--op-space-6);
    max-width: var(--op-content-max-width);
    width: 100%;
    margin: 0 auto;
}

/* Page Header */
.op-page-header {
    margin-bottom: var(--op-space-6);
}

.op-page-title {
    font-size: var(--op-text-2xl);
    font-weight: var(--op-font-bold);
    color: var(--op-text-primary);
    margin: 0 0 var(--op-space-2);
}

.op-page-subtitle {
    font-size: var(--op-text-sm);
    color: var(--op-text-secondary);
    margin: 0;
}

/* Breadcrumb */
.op-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--op-space-2);
    font-size: var(--op-text-sm);
    margin-bottom: var(--op-space-4);
}

.op-breadcrumb-item {
    color: var(--op-text-secondary);
    text-decoration: none;
    transition: color var(--op-transition-fast);
}

.op-breadcrumb-item:hover {
    color: var(--op-primary);
}

.op-breadcrumb-item.active {
    color: var(--op-text-primary);
    font-weight: var(--op-font-medium);
}

.op-breadcrumb-separator {
    color: var(--op-text-tertiary);
}

/* ============================================
   Mobile Overlay
   ============================================ */

.op-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: var(--op-overlay);
    z-index: calc(var(--op-z-fixed) - 1);
    opacity: 0;
    transition: opacity var(--op-transition-base);
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 1024px) {
    .op-sidebar {
        transform: translateX(-100%);
    }

    .op-layout.mobile-menu-open .op-sidebar {
        transform: translateX(0);
    }

    .op-layout.mobile-menu-open .op-mobile-overlay {
        display: block;
        opacity: 1;
    }

    .op-main {
        margin-left: 0;
    }

    .op-mobile-menu-btn {
        display: flex;
    }

    .op-search-box {
        display: none;
    }

    .op-content {
        padding: var(--op-space-4);
    }
}

@media (max-width: 768px) {
    .op-topbar {
        padding: 0 var(--op-space-4);
    }

    .op-topbar-right .op-topbar-btn:not(.op-theme-toggle):not(.op-mobile-menu-btn) {
        display: none;
    }

    .op-topbar-user {
        display: none;
    }
}

@media (max-width: 640px) {
    .op-content {
        padding: var(--op-space-3);
    }

    .op-page-title {
        font-size: var(--op-text-xl);
    }
}

/* ============================================
   Dashboard Grid Layout
   ============================================ */

.op-dashboard-grid {
    display: grid;
    gap: var(--op-space-6);
}

.op-dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--op-space-4);
}

@media (max-width: 1280px) {
    .op-dashboard-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .op-dashboard-kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* Dashboard Sections */
.op-dashboard-section {
    background-color: var(--op-bg-surface);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-lg);
    overflow: hidden;
}

.op-dashboard-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--op-space-4) var(--op-space-6);
    border-bottom: 1px solid var(--op-border-light);
}

.op-dashboard-section-title {
    font-size: var(--op-text-base);
    font-weight: var(--op-font-semibold);
    color: var(--op-text-primary);
    margin: 0;
}

.op-dashboard-section-body {
    padding: var(--op-space-6);
}

/* Chart Placeholder */
.op-chart-placeholder {
    height: 300px;
    background: linear-gradient(135deg, var(--op-bg-hover) 0%, var(--op-bg-surface) 100%);
    border-radius: var(--op-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--op-text-tertiary);
}

/* Activity List */
.op-activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.op-activity-item {
    display: flex;
    align-items: flex-start;
    gap: var(--op-space-4);
    padding: var(--op-space-4) 0;
    border-bottom: 1px solid var(--op-border-light);
}

.op-activity-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.op-activity-item:first-child {
    padding-top: 0;
}

.op-activity-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--op-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.op-activity-icon.primary { background-color: var(--op-primary-light); color: var(--op-primary); }
.op-activity-icon.success { background-color: var(--op-success-light); color: var(--op-success); }
.op-activity-icon.warning { background-color: var(--op-warning-light); color: var(--op-warning); }
.op-activity-icon.error { background-color: var(--op-error-light); color: var(--op-error); }

.op-activity-content {
    flex: 1;
    min-width: 0;
}

.op-activity-title {
    font-size: var(--op-text-sm);
    font-weight: var(--op-font-medium);
    color: var(--op-text-primary);
    margin-bottom: var(--op-space-1);
}

.op-activity-description {
    font-size: var(--op-text-sm);
    color: var(--op-text-secondary);
    margin-bottom: var(--op-space-1);
}

.op-activity-time {
    font-size: var(--op-text-xs);
    color: var(--op-text-tertiary);
}
