* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    min-height: 100vh;
    margin: 0;
}

/* jQuery UI Dialog z-index override to ensure dialogs appear above all content */
.ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-dialog-buttons.ui-draggable,
.ui-dialog {
    z-index: 10000 !important;
}

/* Unified Top Navigation - Phase 1 */
#application-nav {
    background: linear-gradient(135deg, #2d3748, #4a5568) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 0.5rem 1rem;
    height: 60px;
    z-index: 1030;
    position: sticky;
    top: 0;
}

.navbar-brand {
    font-weight: 700 !important;
    font-size: 1.2rem !important;
    color: white !important;
    text-decoration: none !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 0;
}

.navbar-brand img {
    height: 28px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.navbar-brand sup {
    font-size: 0.65rem;
    opacity: 0.8;
}

/* App Selector (clickable link to dashboard) */
#app-selector {
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

#app-selector:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-1px);
}

#app-selector i {
    font-size: 1.1rem;
}

/* Sidebar Toggle Button (Mobile) - Hidden by default on desktop */
#sidebar-toggle {
    display: none !important; /* Hidden by default on desktop */
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

#sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

/* App Selector in Top Nav */
#app-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

#app-selector:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    text-decoration: none;
}

#app-selector i {
    font-size: 1rem;
}

/* Account Dropdown in Top Nav */
#application-nav .nav-link {
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
    border-radius: 8px !important;
    margin: 0 4px !important;
    padding: 8px 16px !important;
}

#application-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* Remove Secondary Navigation (Merged into Sidebar) */
#mainnav {
    display: none;
}

/* Main Layout with Sidebar - Phase 2 */
#wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#page-container {
    display: flex;
    flex: 1;
    position: relative;
}

/* Application-Level Persistent Sidebar */
#app-sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid #e2e8f0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.05);
    padding: 0;
    color: #2d3748;
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    overflow-y: auto;
    z-index: 1010;
    transition: transform 0.3s ease;
}

/* Sidebar for Site Details Pages (Special Treatment) */
#sidenav {
    width: 260px;
    background: white;
    border-right: 1px solid #e2e8f0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.05);
    padding: 0;
    color: #2d3748;
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    overflow-y: auto;
    z-index: 1010;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-back-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #4a5568;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: white;
    border: 1px solid #e2e8f0;
    margin-bottom: 1rem;
}

.sidebar-back-button:hover {
    background: #f8fafc;
    color: #2d3748;
    text-decoration: none;
    transform: translateX(-2px);
}

.sidebar-back-button i {
    font-size: 0.9rem;
}

/* Detail Page Layout */
.detail-page-sidebar {
    width: 260px;
    min-height: calc(100vh - 60px);
    background: white;
    border-right: 1px solid #e2e8f0;
    position: fixed;
    left: 0;
    top: 60px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.detail-page-content {
    margin-left: 260px;
    width: calc(100% - 260px);
    padding: 0 1rem 5rem 1rem;
}

.detail-page-footer {
    margin-left: 260px;
}

/* Model/Controller/Site Detail Sidebar Header */
.sidebar-model-header,
.sidebar-controller-header {
    padding: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
}

.model-title,
.controller-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.model-title i,
.controller-title i {
    color: #ff6b35;
    font-size: 1.1rem;
}

.model-info {
    font-size: 0.85rem;
    color: #718096;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.model-info i {
    font-size: 0.8rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

/* Detail page sidenav items (Bootstrap nav-pills inside #sidenav) */
.detail-page-sidebar #sidenav {
    padding: 0;
}

.detail-page-sidebar #sidenav .nav {
    padding: 0.5rem;
}

.detail-page-sidebar #sidenav .nav-link {
    color: #4a5568;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    font-weight: 500;
}

.detail-page-sidebar #sidenav .nav-link:hover {
    background: #f7fafc;
    color: #2d3748;
}

.detail-page-sidebar #sidenav .nav-link.active {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    font-weight: 600;
}

.detail-page-sidebar #sidenav .nav-link i {
    margin-right: 0.75rem;
    font-size: 1rem;
}

.sidebar-nav .nav-section {
    margin-bottom: 1.5rem;
}

.sidebar-nav .nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #a0aec0;
    padding: 0 1.5rem;
    margin-bottom: 0.5rem;
}

.sidebar-nav .nav-item {
    margin: 0;
}

.sidebar-nav .nav-link {
    display: flex !important;
    align-items: center !important;
    padding: 0.75rem 1.5rem !important;
    color: #4a5568 !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    font-weight: 500 !important;
    border: none !important;
    background: none !important;
    width: 100%;
    text-align: left;
    border-radius: 0 !important;
    margin: 0 !important;
}

.sidebar-nav .nav-link:hover {
    background: #f8fafc !important;
    color: #2d3748 !important;
    transform: translateX(4px);
}

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.1), rgba(247, 147, 30, 0.1)) !important;
    color: #ff6b35 !important;
    border-right: 3px solid #ff6b35 !important;
    font-weight: 600 !important;
}

.sidebar-nav .nav-link i {
    width: 20px !important;
    margin-right: 12px !important;
    font-size: 1.05rem !important;
}

/* Sidebar Overlay (Mobile) */
#sidebar-overlay {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1009;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Site Detail Page Wrapper - Flex Container */
#site-detail-page-wrapper {
    display: flex;
    width: 100%;
    min-height: calc(100vh - 60px);
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 2rem;
    margin-left: 260px;
    min-height: calc(100vh - 60px);
    width: calc(100% - 260px);
    max-width: calc(100% - 260px);
    box-sizing: border-box;
}

/* Content Area (for settings and other pages with sidebar) */
.content-area {
    flex: 1;
    padding: 2rem;
    margin-left: 260px;
    min-height: calc(100vh - 60px);
    width: calc(100% - 260px);
    box-sizing: border-box;
}

/* Site Header */
.site-header {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative;
    overflow: hidden;
}

.site-header::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.05), rgba(247, 147, 30, 0.05));
    border-radius: 50%;
    transform: translate(50px, -50px);
}

.site-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 0.5rem 0;
    position: relative;
    z-index: 1;
}

.site-info {
    /* display: flex; */
    align-items: center;
    gap: 2rem;
    position: relative;
    z-index: 1;
}

.site-region {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #718096;
    font-size: 1.1rem;
    font-weight: 500;
}

.site-domain {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    position: relative;
}

.site-domain a {
    color: #ff6b35;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
    transition: all 0.2s ease;
}

.site-domain a:hover {
    text-decoration: underline;
    max-width: none;
    white-space: normal;
    word-break: break-all;
}

.site-domain .copy-url-btn {
    background: transparent;
    border: none;
    color: #718096;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.site-domain .copy-url-btn:hover {
    opacity: 1;
    color: #ff6b35;
}

.site-domain .copy-url-btn:active {
    transform: scale(0.9);
}

.site-domain .copy-tooltip {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #2d3748;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.site-domain .copy-tooltip.show {
    opacity: 1;
}

/* Content Sections */
.content-section {
    display: none;
    width: 100%;
    background: white;
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.8);
    overflow: visible;
    box-sizing: border-box;
}

.content-section.active {
    display: block;
}

/* Table Container */
.table-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

/* Filter Panel */
.filter-panel {
    padding: 2rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.filter-panel h5 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 1.5rem 0;
    display: flex;
    align-items: center;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.filter-group select,
.filter-group input {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: white;
    color: #2d3748;
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: #ff6b35;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.filter-group select[multiple] {
    min-height: 100px;
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-filter,
.btn-clear {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-filter {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.btn-filter:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
    background: linear-gradient(135deg, #e55a2b, #e8841a);
}

.btn-clear {
    background: white;
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-clear:hover {
    background: #f8fafc;
    border-color: #cbd5e0;
}

/* Log Level Badges */
.log-badge {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.log-badge.debug {
    background: #e0e7ff;
    color: #4338ca;
}

.log-badge.info {
    background: #dbeafe;
    color: #1e40af;
}

.log-badge.warning {
    background: #fef3c7;
    color: #b45309;
}

.log-badge.error {
    background: #fee2e2;
    color: #dc2626;
}

.log-badge.critical {
    background: #fecaca;
    color: #991b1b;
    font-weight: 800;
}

.section-header {
    width: 100%;
    padding: 2rem 2rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    border-radius: 16px 16px 0 0;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.section-content {
    width: 100%;
    padding: 2rem;
    box-sizing: border-box;
}

/* Enhanced Buttons */
.btn-new {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.btn-new:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
    background: linear-gradient(135deg, #e55a2b, #e8841a);
    color: white;
    text-decoration: none;
}

.btn-new:active {
    transform: translateY(0);
}

/* Modern Button Variants (used in settings page) */
.btn-modern {
    border-radius: 10px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-modern i {
    font-size: 0.9rem;
}

.btn-modern-primary {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.btn-modern-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
    background: linear-gradient(135deg, #e55a2b, #e8841a);
    color: white;
}

.btn-modern-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-modern-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, #0d9668, #047857);
    color: white;
}

.btn-modern-outline {
    background: transparent;
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-modern-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e0;
    color: #2d3748;
}

/* Settings page form layouts */
.input-group-modern {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
}

.input-group-modern > div:first-child {
    flex: 1;
}

.password-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.password-grid .btn-modern {
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    .input-group-modern {
        flex-direction: column;
        align-items: stretch;
    }

    .password-grid {
        grid-template-columns: 1fr;
    }
}

/* Settings Cards */
.settings-grid {
    display: grid;
    gap: 1.5rem;
}

.setting-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: visible;
    transition: box-shadow 0.3s ease;
}

.setting-card:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.setting-card-header {
    background: #f8fafc;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    color: #2d3748;
    border-radius: 12px 12px 0 0;
}

.setting-card-body {
    padding: 1.5rem;
}

.setting-card-body p {
    color: #718096;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.form-control, .form-select {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.form-control:focus, .form-select:focus {
    border-color: #ff6b35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
    background: white;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    border: none;
    border-radius: 12px;
    padding: 12px 32px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
    background: linear-gradient(135deg, #e55a2b, #e8841a);
}

/* DataTable Enhancements */
.dataTables_wrapper {
    width: 100%;
    padding: 2rem 0 0 0;
    box-sizing: border-box;
}

.dataTables_wrapper table {
    width: 100% !important;
}

.dataTables_length,
.dataTables_filter {
    margin-bottom: 1.5rem;
    padding: 0 2rem;
}

.dataTables_length select,
.dataTables_filter input {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.dataTables_length select:focus,
.dataTables_filter input:focus {
    border-color: #ff6b35;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.dataTables_filter {
    text-align: right;
}

table.dataTable {
    border-collapse: separate;
    border-spacing: 0;
    width: 100% !important;
}

table.dataTable thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    color: #2d3748;
    font-weight: 600;
    padding: 1rem 2rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table.dataTable tbody td {
    padding: 1rem 2rem;
    border-bottom: 1px solid #f1f5f9;
    color: #4a5568;
    font-size: 0.95rem;
}

table.dataTable tbody tr {
    transition: all 0.2s ease;
}

table.dataTable tbody tr:hover {
    background: #f8fafc;
}

.dataTables_info {
    color: #718096;
    font-size: 0.9rem;
    padding: 1rem 2rem 2rem;
}

.dataTables_paginate {
    padding: 1rem 2rem 2rem;
}

.dataTables_paginate .paginate_button {
    background: white;
    border: 1px solid #e2e8f0;
    color: #4a5568 !important;
    margin: 0 2px;
    border-radius: 6px;
    padding: 8px 12px;
    transition: all 0.2s ease;
}

.dataTables_paginate .paginate_button:hover {
    background: #f8fafc;
    border-color: #cbd5e0;
    color: #2d3748 !important;
}

.dataTables_paginate .paginate_button.current {
    background: linear-gradient(135deg, #ff6b35, #f7931e) !important;
    border-color: #ff6b35 !important;
    color: white !important;
}

/* Footer */
footer {
    background: linear-gradient(135deg, #2d3748, #4a5568);
    margin-top: auto;
    margin-left: 260px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-content {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    padding: 1rem 1.5rem;
}

/* Loading Modal */
.modal.white {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.spinner-wrapper {
    color: #ff6b35;
}

/* Phase 3: Responsive Behavior */

/* Desktop (>768px) - Ensure sidebar is visible */
@media (min-width: 769px) {
    #app-sidebar,
    #sidenav {
        display: block;
        transform: translateX(0);
    }
}

/* Tablet (768px - 1200px) */
@media (max-width: 1200px) and (min-width: 769px) {
    #app-sidebar,
    #sidenav {
        width: 220px;
    }

    .main-content,
    .content-area {
        margin-left: 220px;
        width: calc(100% - 220px);
        max-width: calc(100vw - 220px);
    }

    footer {
        margin-left: 220px;
    }

    .sidebar-nav .nav-link {
        padding: 0.7rem 1.25rem !important;
        font-size: 0.9rem;
    }

    .sidebar-nav .nav-link i {
        font-size: 1rem !important;
    }
}

/* Mobile (<768px) */
@media (max-width: 768px) {
    /* Show sidebar toggle button on mobile */
    #sidebar-toggle {
        display: block !important;
    }

    /* Hide app selector on mobile */
    #app-selector {
        display: none;
    }

    /* Sidebar becomes drawer overlay */
    #app-sidebar,
    #sidenav {
        position: fixed;
        top: 60px;
        left: 0;
        width: 280px;
        height: calc(100vh - 60px);
        transform: translateX(-100%);
        z-index: 1020;
    }

    #app-sidebar.active,
    #sidenav.active {
        transform: translateX(0);
    }

    #page-container,
    #site-detail-page-wrapper {
        flex-direction: column;
    }

    .main-content,
    .content-area {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        padding: 1.5rem 1rem;
    }

    .site-domain a {
        max-width: 160px;
    }

    footer {
        margin-left: 0;
    }

    .site-header {
        padding: 1.5rem;
    }

    .site-title {
        font-size: 2rem;
    }

    .site-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1.5rem;
    }

    .section-content {
        padding: 1.5rem;
    }

    /* Adjust navbar for mobile */
    .navbar-brand {
        font-size: 1rem !important;
    }

    .navbar-brand img {
        height: 24px;
    }

    /* Filter panel mobile adjustments */
    .filter-panel {
        padding: 1.5rem;
    }

    .filter-row {
        flex-direction: column;
        gap: 1rem;
    }

    .filter-group {
        width: 100%;
        min-width: 0;
    }

    .filter-actions {
        width: 100%;
        flex-direction: column;
    }

    .btn-filter,
    .btn-clear {
        width: 100%;
        justify-content: center;
    }
}

/* Very Small Mobile (<480px) */
@media (max-width: 480px) {
    #application-nav {
        padding: 0.5rem;
    }

    .navbar-brand {
        font-size: 0.9rem !important;
    }

    .navbar-brand sup {
        display: none;
    }

    #app-sidebar,
    #sidenav {
        width: 100%;
    }

    .main-content {
        padding: 1rem;
    }

    .site-header {
        padding: 1rem;
    }

    .site-domain a {
        max-width: 140px;
        font-size: 0.85rem;
    }

    .site-domain .copy-url-btn {
        font-size: 0.8rem;
        padding: 0.2rem;
    }

    .section-heading,
    .site-title {
        font-size: 1.5rem;
    }
}

/* Phase 4: Polish & Accessibility */

/* Enhanced Focus Indicators */
*:focus-visible {
    outline: 3px solid #ff6b35;
    outline-offset: 2px;
    border-radius: 4px;
}

#sidebar-toggle:focus-visible,
.sidebar-nav .nav-link:focus-visible,
#app-selector:focus-visible,
.nav-link:focus-visible,
.btn-new:focus-visible,
.btn-primary:focus-visible {
    outline: 3px solid #ff6b35;
    outline-offset: 2px;
}

/* Skip to main content link (for keyboard navigation) */
.skip-to-main {
    position: absolute;
    top: -100px;
    left: 0;
    background: #ff6b35;
    color: white;
    padding: 1rem 2rem;
    text-decoration: none;
    font-weight: 600;
    z-index: 9999;
    transition: top 0.3s ease;
}

.skip-to-main:focus {
    top: 0;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Enhanced Sidebar Transitions */
#app-sidebar,
#sidenav {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar-overlay {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Loading States */
.sidebar-loading {
    opacity: 0.6;
    pointer-events: none;
}

.sidebar-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid #e2e8f0;
    border-top-color: #ff6b35;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Hover and Active State Enhancements */
.sidebar-nav .nav-link {
    position: relative;
    overflow: hidden;
}

.sidebar-nav .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.sidebar-nav .nav-link:hover::before {
    transform: scaleY(1);
}

.sidebar-nav .nav-link.active::before {
    transform: scaleY(1);
}

/* Button Ripple Effect */
.btn-new,
.btn-primary {
    position: relative;
    overflow: hidden;
}

.btn-new::after,
.btn-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-new:active::after,
.btn-primary:active::after {
    width: 300px;
    height: 300px;
}

/* Tooltip Support */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: #2d3748;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 9999;
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* Print Styles */
@media print {
    #application-nav,
    #app-sidebar,
    #sidenav,
    #sidebar-toggle,
    #sidebar-overlay,
    footer {
        display: none !important;
    }

    .main-content {
        max-width: 100%;
        padding: 0;
    }

    #page-container {
        display: block;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    #application-nav {
        border-bottom: 2px solid white;
    }

    #app-sidebar,
    #sidenav {
        border-right: 2px solid #2d3748;
    }

    .sidebar-nav .nav-link.active {
        border-right: 4px solid #ff6b35 !important;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    #app-sidebar,
    #sidenav,
    #sidebar-overlay {
        transition: none !important;
    }
}

/* Content sections are controlled by Bootstrap's d-none class in HTML */
/* ===================================================================
   Configuration Page Styles - AI Error Correction & App Settings
   =================================================================== */

/* Config Cards */
.config-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.config-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.config-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f1f5f9;
}

.config-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.config-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.config-card-description {
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* Stat Cards */
.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 500;
}

/* Form Grid Layouts */
.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 992px) {
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Form Elements */
.form-label {
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-control,
.form-select {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #cbd5e1;
    cursor: pointer;
}

.form-check-input:checked {
    background-color: #667eea;
    border-color: #667eea;
}

.form-check-label {
    margin-left: 0.5rem;
    color: #475569;
    cursor: pointer;
}

.form-check-label strong {
    color: #1e293b;
    font-weight: 600;
}

.form-check-label small {
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.form-text {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 0.5rem;
}

/* Form Switches */
.form-switch .form-check-input {
    width: 2.5rem;
    height: 1.25rem;
    background-color: #cbd5e1;
    border: none;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: #10b981;
}

/* Range Slider */
.form-range {
    height: 0.5rem;
    background: #e2e8f0;
    border-radius: 1rem;
    cursor: pointer;
}

.form-range::-webkit-slider-thumb {
    width: 1.25rem;
    height: 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.form-range::-moz-range-thumb {
    width: 1.25rem;
    height: 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

/* Buttons */
.btn {
    border-radius: 8px;
    padding: 0.65rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-outline-danger {
    border: 2px solid #ef4444;
    color: #ef4444;
    background: white;
}

.btn-outline-danger:hover {
    background: #ef4444;
    color: white;
}

.btn-lg {
    padding: 0.85rem 2rem;
    font-size: 1rem;
}

/* Badge Styles */
.badge {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
}

.badge i {
    margin-right: 0.25rem;
}

/* Content Sections */
.content-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.content-section.active {
    display: block;
}

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

/* Loading State */
.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* Alert Styles */
.alert {
    border-radius: 10px;
    padding: 1rem 1.25rem;
    border: none;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
}

.alert-info i {
    color: #3b82f6;
}

/* AI Analysis Modal Styles */
#aiAnalysisModal .modal-dialog {
    max-width: 900px;
}

#aiAnalysisModal .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: none;
    padding: 1.5rem;
    border-radius: 8px 8px 0 0;
}

#aiAnalysisModal .modal-header .modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

#aiAnalysisModal .modal-header .badge {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

#aiAnalysisModal .modal-header .close {
    color: white;
    opacity: 0.9;
    text-shadow: none;
    font-size: 1.5rem;
    font-weight: 300;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    cursor: pointer;
}

#aiAnalysisModal .modal-header .close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

#aiAnalysisModal .modal-header .close:focus {
    outline: none;
}

#aiAnalysisModal .modal-body {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
    background: #f8fafc;
}

#aiAnalysisModal .analysis-section {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

#aiAnalysisModal .analysis-section:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

#aiAnalysisModal .analysis-section h6 {
    color: #2d3748;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#aiAnalysisModal .analysis-section h6 i {
    color: #667eea;
    font-size: 1.25rem;
}

#aiAnalysisModal .analysis-section p {
    margin-bottom: 0.75rem;
    color: #4a5568;
    line-height: 1.6;
}

#aiAnalysisModal .analysis-section p strong {
    color: #2d3748;
    font-weight: 600;
}

#aiAnalysisModal .analysis-text {
    background: #f7fafc;
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    line-height: 1.7;
    white-space: pre-wrap;
    font-size: 0.95rem;
}

#aiAnalysisModal .code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: 10px;
    overflow-x: auto;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    border: 1px solid #334155;
}

#aiAnalysisModal .code-block::before {
    content: 'PHP';
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: #667eea;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

#aiAnalysisModal .code-block code {
    color: #e2e8f0;
    display: block;
    margin-top: 1.5rem;
}

#aiAnalysisModal .modal-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 1.25rem 2rem;
}

#aiAnalysisModal .modal-footer .btn {
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

#aiAnalysisModal .modal-footer .btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    border: none;
}

#aiAnalysisModal .modal-footer .btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.4);
}

#aiAnalysisModal .modal-footer .btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: none;
    color: white;
}

#aiAnalysisModal .modal-footer .btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

#aiAnalysisModal .modal-footer .btn-danger {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    border: none;
}

#aiAnalysisModal .modal-footer .btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 101, 101, 0.4);
}

#aiAnalysisModal .modal-footer .btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
    border: none;
}

#aiAnalysisModal .modal-footer .btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-1px);
}
