@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-rgb: 30, 64, 175;
    --accent: #0284c7;
    --border-color: #e2e8f0;
    --success: #16a34a;
    --error: #dc2626;
    --warning: #ea580c;
}

[data-theme="dark"] {
    --bg-primary: #090d16;
    --bg-card: #111827;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-rgb: 59, 130, 246;
    --border-color: #1f2937;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

header {
    background-color: var(--cr-blue, #002B7F);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    margin-bottom: 2rem;
}

.header-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section h1 {
    font-size: 1.35rem;
    font-weight: 800;
    color: white !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-section h1 span.cr-red {
    color: #CE1126;
}

.logo-section h1 span.crm-tag {
    font-size: 0.85rem;
    font-weight: 400;
    opacity: 0.8;
}

.logo-section p {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 0.1rem;
    display: none;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-btn {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.8) !important;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.45rem 0.85rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    cursor: pointer;
}

.nav-btn:hover {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.15) !important;
}

.nav-btn.active {
    color: white !important;
    background-color: #CE1126 !important;
    box-shadow: 0 4px 12px rgba(206, 17, 38, 0.3) !important;
}

/* Card Styling */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 2rem;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
    transition: box-shadow 0.3s, transform 0.3s;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Form Elements */
.form-group {
    margin-bottom: 1.25rem;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    background-color: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 0.75rem;
    color: var(--text-main);
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--cr-blue, #002B7F);
    box-shadow: 0 0 0 3px rgba(0, 43, 127, 0.15);
}

.form-control[readonly], .form-control[disabled] {
    opacity: 0.75;
    background-color: var(--border-color);
    cursor: not-allowed;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.3);
}

.btn-secondary {
    color: var(--text-main);
    background-color: var(--bg-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-accent {
    color: white;
    background-color: var(--accent);
}

.btn-accent:hover {
    opacity: 0.9;
}

.btn-full {
    width: 100%;
}

/* Row wrapper for testing buttons */
.test-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.test-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--text-muted);
    position: relative;
}

.test-status.success {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.test-status.error {
    background-color: var(--error);
    box-shadow: 0 0 8px var(--error);
}

.test-status.loading {
    background-color: var(--warning);
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.2); opacity: 1; }
}

.test-message {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    flex-grow: 1;
}

/* Custom Cam Container */
.cam-btn-container {
    position: absolute;
    right: 8px;
    top: 30px;
    z-index: 10;
}

.cam-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    transition: color 0.2s;
}

.cam-btn:hover {
    color: var(--primary);
}

/* Alert Box */
.alert {
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    display: flex;
    align-items: start;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.alert-success {
    background-color: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.alert-error {
    background-color: #fef2f2;
    border-color: #fee2e2;
    color: #991b1b;
}

.hidden {
    display: none !important;
}

/* Auto-complete Dropdown */
.autocomplete-list {
    position: absolute;
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
    list-style: none;
    margin-top: 4px;
}

.autocomplete-list li {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.autocomplete-list li:hover {
    background-color: var(--bg-primary);
}

.autocomplete-list li:last-child {
    border-bottom: none;
}
/* ==========================================================================
   RESPONSIVE & ADAPTIVE STYLING OVERRIDES (MOBILE FIRST INTEGRATION)
   ========================================================================== */

/* Narrow container for forms (Registration/Login cozy mobile-app feel) */
.container-narrow {
    max-width: 550px;
    margin: 0 auto;
    padding: 0 1.25rem 2rem 1.25rem;
}

/* Flag Line Theme */
.flag-line {
    height: 4px;
    width: 100%;
    display: flex;
}
.flag-line-blue { width: 20%; background-color: #002B7F; height: 100%; }
.flag-line-white { width: 20%; background-color: #FFFFFF; height: 100%; }
.flag-line-red { width: 20%; background-color: #CE1126; height: 100%; }

/* Section Header Styles */
.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 2rem 0 1.25rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
[data-theme="dark"] .section-title {
    color: #94a3b8;
}
.section-title:first-of-type {
    margin-top: 0.5rem;
}
.section-title i {
    font-size: 1rem;
}
.title-icon-blue {
    color: #002B7F;
}
.title-icon-red {
    color: #CE1126;
}
[data-theme="dark"] .title-icon-blue {
    color: var(--primary-light);
}

/* Grid that remains 2-column on mobile */
.grid-2-mobile {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* OCR Scan Banner Grids */
.grid-scan {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.scan-banner {
    background: linear-gradient(135deg, #e6eef9, #f8fafc);
    border: 1px solid #dbeafe;
    border-radius: 0.75rem;
    padding: 1rem;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 120px;
}
[data-theme="dark"] .scan-banner {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    border-color: #1f2937;
}

.scan-banner-info h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: #002B7F;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
}
[data-theme="dark"] .scan-banner-info h4 {
    color: var(--primary-light);
}
.scan-banner-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.scan-btn-cr {
    background-color: #002B7F;
    color: white;
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s;
    justify-content: center;
    white-space: nowrap;
}
.scan-btn-cr:hover {
    background-color: #001f5c;
    transform: translateY(-1px);
}
[data-theme="dark"] .scan-btn-cr {
    background-color: var(--primary);
}
[data-theme="dark"] .scan-btn-cr:hover {
    background-color: var(--primary-light);
}

/* Switch Toggles (iOS style) */
.switch-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.switch-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    user-select: none;
}
.switch-control {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
    flex-shrink: 0;
}
.switch-control input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .25s;
    border-radius: 34px;
}
.switch-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .25s;
    border-radius: 50%;
}
input:checked + .switch-slider {
    background-color: #002B7F;
}
[data-theme="dark"] input:checked + .switch-slider {
    background-color: var(--primary);
}
input:checked + .switch-slider:before {
    transform: translateX(20px);
}

/* Submit Provision button */
.btn-submit-cr {
    color: white;
    background: #CE1126;
    box-shadow: 0 4px 12px rgba(206, 17, 38, 0.25);
    border: none;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}
.btn-submit-cr:hover {
    background-color: #b00e1f;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(206, 17, 38, 0.35);
}
.btn-submit-cr:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .container {
        padding: 1.25rem 1rem;
    }
    
    .container-narrow {
        padding: 0 1rem 1.5rem 1rem;
    }

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

    .logo-section {
        width: 100%;
        text-align: left;
    }

    .nav-links {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.5rem;
    }

    .nav-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        text-align: center;
        border-radius: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
    }

    .card {
        padding: 1.25rem 1rem;
        border-radius: 1rem;
    }

    /* Stack regular grid elements on mobile, but keep grid-2-mobile intact */
    .grid-2 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .grid-2-mobile {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .grid-scan {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Table horizontal scroll wrapper spacing */
    div[style*="overflow-x: auto"] {
        margin-left: -1rem;
        margin-right: -1rem;
        border-radius: 0 !important;
        border-left: none;
        border-right: none;
    }

    table {
        min-width: 700px; /* Force scrollable content for complex tables */
    }
    
    /* Make inputs slightly larger for touch targets */
    .form-control {
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }
    
    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
}

/* Extra small mobile adjustments */
@media (max-width: 480px) {
    .nav-links {
        grid-template-columns: 1fr 1fr; /* 2 columns layout on very narrow screens */
    }
    
    /* Logout button occupies full row at bottom */
    #btnLogout {
        grid-column: span 2;
    }
}

/* Table Inputs & Columns Mobile Adaptive Controls */
table th, table td {
    white-space: nowrap;
}
table .form-control {
    width: 100%;
    min-width: 130px;
}
table input.router-port-input, table input.plan-vlan-input, table input.mgmt-vlan-input {
    min-width: 80px !important;
}
table input.router-host-input {
    min-width: 150px !important;
}
table input.router-user-input {
    min-width: 110px !important;
}
table input.router-password-input {
    min-width: 130px !important;
}
table select.plan-name-select {
    min-width: 220px !important;
}
table input.plan-pool-input {
    min-width: 220px !important;
}
table input.plan-local-input {
    min-width: 150px !important;
}
table input.mgmt-desc-input {
    min-width: 200px !important;
}

/* Card Header Flex Layout */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 1rem;
}
@media (max-width: 600px) {
    .card-header-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .card-header-flex button {
        width: 100%;
    }
}

/* --- OLT & ONU HEALTH DASHBOARD STYLES --- */
.olt-chassis-wrapper {
    background: #0f172a;
    border-radius: 1rem;
    padding: 1.5rem;
    color: #f8fafc;
    border: 1px solid #1e293b;
    margin-bottom: 2rem;
}
.olt-chassis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid #1e293b;
    padding-bottom: 0.75rem;
}
.olt-chassis-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #38bdf8;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.olt-chassis-info {
    font-size: 0.85rem;
    color: #94a3b8;
}
.olt-chassis-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0.5rem;
    background: #020617;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid #1e293b;
    min-height: 120px;
}
.olt-slot {
    background: #1e293b;
    border-radius: 0.375rem;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 90px;
    border: 1px solid #334155;
    transition: all 0.2s;
    text-align: center;
}
.olt-slot.active {
    background: #1e3a8a;
    border-color: #3b82f6;
    box-shadow: inset 0 0 10px rgba(59, 130, 246, 0.4);
}
.olt-slot.failed {
    background: #4c0519;
    border-color: #f43f5e;
    box-shadow: inset 0 0 10px rgba(244, 63, 94, 0.4);
}
.olt-slot.empty {
    background: #0f172a;
    border-color: #1e293b;
    opacity: 0.5;
}
.olt-slot-id {
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    background: #020617;
    border-radius: 0.25rem;
    padding: 0.1rem 0.35rem;
    margin-bottom: 0.25rem;
}
.olt-slot.active .olt-slot-id {
    color: #93c5fd;
}
.olt-slot.failed .olt-slot-id {
    color: #fca5a5;
}
.olt-slot-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #f1f5f9;
}
.olt-slot-status {
    font-size: 0.6rem;
    padding: 0.15rem 0.3rem;
    border-radius: 0.25rem;
    font-weight: 600;
    margin-top: 0.25rem;
    text-transform: uppercase;
}
.olt-slot-status.normal {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}
.olt-slot-status.active_normal {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}
.olt-slot-status.failed {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}
.olt-slot-status.offline {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

/* OLT summary metrics cards */
.olt-metrics-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}
@media (max-width: 1024px) {
    .olt-metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 640px) {
    .olt-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
.olt-metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}
.olt-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.olt-metric-icon {
    font-size: 1.5rem;
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.olt-metric-info {
    display: flex;
    flex-direction: column;
}
.olt-metric-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
}
.olt-metric-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Specific metric card icon themes */
.olt-metric-icon.total { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.olt-metric-icon.online { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.olt-metric-icon.offline { background: rgba(100, 116, 139, 0.1); color: #64748b; }
.olt-metric-icon.deactivated { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.olt-metric-icon.warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }

/* Signal pills for optical power */
.signal-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 2rem;
}
.signal-badge.good {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}
.signal-badge.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}
.signal-badge.critical {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}
.signal-badge.offline {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

/* Detail modal table formatting */
.modal-detail-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
.modal-detail-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}
.modal-detail-table td:first-child {
    font-weight: 600;
    color: var(--text-muted);
    width: 40%;
}
.modal-detail-table td:last-child {
    color: var(--text-main);
}
