/* OpenEstimate Frontend - Bootstrap 5 Enhanced */
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css');

:root {
    --oe-sidebar-width: 260px;
    --oe-topbar-height: 60px;
    --oe-primary: #4f46e5;
    --oe-sidebar-bg: #1e293b;
    --oe-sidebar-hover: #334155;
    --oe-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Break out of WordPress theme constraints */
.oe-fe-portal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #f8f9fa !important;
    overflow: hidden !important;
    z-index: 999999999 !important;
}

/* Hide WordPress/Elementor theme elements when portal is active */
body.oe-portal-active {
    overflow: hidden !important;
}

body.oe-portal-active #wpadminbar,
body.oe-portal-active .site-header,
body.oe-portal-active .site-footer,
body.oe-portal-active header,
body.oe-portal-active footer,
body.oe-portal-active nav.navigation,
body.oe-portal-active .elementor-location-header,
body.oe-portal-active .elementor-location-footer,
body.oe-portal-active #site-header,
body.oe-portal-active #masthead,
body.oe-portal-active #colophon {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Fallback using :has() for modern browsers */
body:has(.oe-fe-portal) {
    overflow: hidden !important;
}

body:has(.oe-fe-portal) #wpadminbar,
body:has(.oe-fe-portal) .site-header,
body:has(.oe-fe-portal) .site-footer,
body:has(.oe-fe-portal) header:not(.oe-fe-portal *),
body:has(.oe-fe-portal) footer:not(.oe-fe-portal *),
body:has(.oe-fe-portal) .elementor-location-header,
body:has(.oe-fe-portal) .elementor-location-footer {
    display: none !important;
}

/* Top Navigation Bar */
.oe-fe-portal .navbar.fixed-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--oe-topbar-height);
    z-index: 1050;
    margin: 0;
}

/* Sidebar */
.oe-sidebar {
    position: fixed;
    left: 0;
    top: var(--oe-topbar-height);
    bottom: 0;
    width: var(--oe-sidebar-width);
    background: var(--oe-sidebar-bg);
    z-index: 1040;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--oe-transition);
}

.oe-sidebar-header {
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.oe-sidebar-logo {
    max-width: 80px;
    max-height: 50px;
    margin-bottom: 0.5rem;
}

.oe-sidebar-title {
    font-size: 1rem;
    margin: 0;
    color: white;
    font-weight: 600;
}

/* Sidebar Navigation */
.oe-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.oe-sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: var(--oe-transition);
}

.oe-sidebar-link:hover {
    background: var(--oe-sidebar-hover);
    color: white;
}

.oe-sidebar-link.active {
    background: linear-gradient(135deg, var(--oe-primary), #6366f1);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.oe-sidebar-icon {
    font-size: 1.25rem;
    width: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.oe-sidebar-label {
    margin-left: 1rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Main Content Area */
.oe-main-content {
    position: fixed;
    top: var(--oe-topbar-height);
    left: var(--oe-sidebar-width);
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f8f9fa;
    transition: var(--oe-transition);
}

/* Dashboard Stats */
.oe-stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: var(--oe-transition);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.oe-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.oe-fe-stat-icon {
    width: 60px;
    height: 60px;
    font-size: 1.75rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.oe-fe-stat-icon.stat-blue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.oe-fe-stat-icon.stat-green {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    color: #065f46;
}

.oe-fe-stat-icon.stat-orange {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: #92400e;
}

.oe-fe-stat-icon.stat-purple {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #6b21a8;
}

/* Estimate Builder Items */
.oe-item-row {
    background: #f8f9fa;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: grid;
    grid-template-columns: 2fr 1fr 1.5fr 1fr 1fr 1fr auto;
    gap: 0.75rem;
    align-items: start;
}

.oe-item-row input,
.oe-item-row select,
.oe-item-row textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.oe-item-row input:focus,
.oe-item-row select:focus,
.oe-item-row textarea:focus {
    border-color: var(--oe-primary);
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.15);
    outline: none;
}

.oe-item-row button {
    margin-top: 1.75rem;
}

/* Sidebar Overlay for Mobile */
.oe-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: var(--oe-transition);
}

.oe-fe-portal.oe-sidebar-open .oe-sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

/* Responsive - Tablets and smaller */
@media (max-width: 991.98px) {
    .oe-sidebar {
        transform: translateX(-100%);
    }
    
    .oe-fe-portal.oe-sidebar-open .oe-sidebar {
        transform: translateX(0);
    }
    
    .oe-main-content {
        left: 0;
    }
    
    .oe-item-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    
    .oe-item-row > *:first-child {
        grid-column: span 2;
    }
}

/* Responsive - Mobile */
@media (max-width: 767.98px) {
    :root {
        --oe-topbar-height: 56px;
    }
    
    .oe-fe-portal {
        padding-top: var(--oe-topbar-height);
    }
    
    .navbar.fixed-top {
        height: var(--oe-topbar-height);
    }
    
    .navbar.fixed-top .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .oe-item-row {
        grid-template-columns: 1fr;
        padding: 0.75rem;
    }
    
    .oe-item-row > * {
        grid-column: span 1 !important;
    }
    
    .oe-stat-card {
        padding: 1.25rem;
    }
    
    .oe-fe-stat-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table thead th,
    .table tbody td {
        padding: 0.5rem;
    }
    
    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
    
    .card-body {
        padding: 1.25rem !important;
    }
}

/* Very Small Mobile */
@media (max-width: 575.98px) {
    .navbar-brand {
        font-size: 1rem !important;
    }
    
    .oe-sidebar {
        width: 280px;
    }
    
    h2, .h2 {
        font-size: 1.5rem;
    }
    
    h3, .h3 {
        font-size: 1.25rem;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .oe-sidebar,
    .oe-sidebar-overlay,
    .btn,
    .oe-sidebar-toggle {
        display: none !important;
    }
    
    .oe-fe-portal {
        position: relative;
        height: auto;
    }
    
    .oe-main-content {
        position: relative;
        left: 0;
        top: 0;
    }
}

/* Custom Scrollbar for Sidebar */
.oe-sidebar::-webkit-scrollbar {
    width: 6px;
}

.oe-sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

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

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

/* Additional Bootstrap Enhancements */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: var(--oe-transition);
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8f9fa;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: #6c757d;
    border-bottom: 2px solid #dee2e6;
}

.table tbody tr {
    transition: background 0.2s;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

.badge {
    font-weight: 500;
    padding: 0.5rem 0.875rem;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--oe-primary);
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.15);
}

.btn-primary {
    background-color: var(--oe-primary);
    border-color: var(--oe-primary);
}

.btn-primary:hover {
    background-color: #4338ca;
    border-color: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Login Page */
.oe-login-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--oe-primary), #6366f1);
    z-index: 1000000000;
}
