/**
 * Fiber Distribution and Management Console
 * Main Stylesheet
 * Mobile-First Design
 */

:root {
    --primary-color: #2563EB;
    --secondary-color: #6B7280;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --info-color: #3B82F6;
    --fat-color: #F97316;
    --bg-color: #F9FAFB;
    --text-color: #1F2937;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden; /* Prevent body scroll, map handles it */
}

/* --- Global Loader --- */
.loader-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.loader-overlay.active {
    display: flex;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Login Page --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
    background-color: #f3f4f6;
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
}

/* --- Dashboard Layout --- */
.dashboard-container {
    position: relative;
    height: 100vh;
    width: 100%;
}

/* Navbar */
.navbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    height: 60px;
}

.nav-brand {
    font-weight: bold;
    color: var(--primary-color);
    display: none; /* Hidden on very small screens if needed, shown on larger */
}
@media (min-width: 360px) {
    .nav-brand { display: block; margin-right: 10px; }
}

.nav-menu .btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

/* Navbar Search */
.search-container {
    position: relative;
    flex: 1;
    margin: 0 10px;
    max-width: 400px;
}

#search-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    background-color: #f3f4f6;
    transition: background-color 0.2s, border-color 0.2s;
}

#search-input:focus {
    background-color: white;
    border-color: var(--primary-color);
    outline: none;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    display: none;
}

.search-dropdown.active {
    display: block;
}

.search-result-item {
    padding: 10px 15px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #f9fafb; }
.search-meta { font-size: 0.75rem; color: var(--secondary-color); }

/* Map */
#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* --- UI Components --- */

/* Floating Action Button (FAB) */
.fab {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 900;
    transition: transform 0.2s;
    border: none;
}

.fab:active {
    transform: scale(0.95);
}

/* Bottom Sheet / Info Panel */
.info-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 1100;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.info-panel.active {
    transform: translateY(0);
}

.panel-content {
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 40px; /* Safe area for mobile */
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-color);
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Add Menu (Center Modal Style) */
.add-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 320px;
    z-index: 1200;
    display: none;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.add-menu.active {
    display: block;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

input, select, textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background-color: white;
}

button.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    margin-bottom: 10px;
}

.btn-primary { background-color: var(--primary-color); color: white; }
.btn-secondary { background-color: #e5e7eb; color: var(--text-color); }
.btn-danger { background-color: var(--danger-color); color: white; }
.btn-orange { background-color: var(--fat-color); color: white; }
.btn-blue { background-color: var(--info-color); color: white; }
.btn-block { display: block; width: 100%; }

/* --- Custom Markers --- */
.custom-marker-fat {
    background: none;
    border: none;
}

.marker-fat-inner {
    width: 40px;
    height: 40px;
    background-color: var(--fat-color);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    color: white;
    font-weight: bold;
    font-size: 10px;
    transition: background-color 0.3s;
}

/* Utilization Colors for FATs */
.marker-fat-inner.util-low { background-color: var(--success-color); }   /* < 70% */
.marker-fat-inner.util-med { background-color: var(--warning-color); }   /* 70-90% */
.marker-fat-inner.util-high { background-color: var(--danger-color); }   /* > 90% */

.marker-fat-inner[data-status="inactive"] { background-color: var(--secondary-color) !important; }
.marker-fat-inner[data-status="maintenance"] { background-color: #7c2d12 !important; } /* Dark amber */

.custom-marker-customer {
    background: none;
    border: none;
}

.marker-customer-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.status-active { background-color: var(--success-color); }
.status-inactive { background-color: var(--danger-color); }
.status-pending { background-color: var(--info-color); }
.status-suspended { background-color: var(--secondary-color); }

/* --- Badges & Port Matrix --- */
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    color: white;
}

.badge.active { background-color: var(--success-color); }
.badge.inactive { background-color: var(--danger-color); }
.badge.maintenance { background-color: var(--warning-color); }
.badge.pending { background-color: var(--info-color); }

/* Port Matrix Grid */
.port-matrix {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 columns */
    gap: 8px;
    margin: 15px 0;
}

.port-box {
    aspect-ratio: 1; /* Square */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: bold;
    color: white;
    cursor: default;
    background-color: var(--success-color); /* Default Free */
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    position: relative;
}

.port-box.used {
    background-color: var(--danger-color);
    cursor: pointer;
}

.port-box .tooltip {
    display: none; /* Tooltips handled by simple title attr for now or custom later */
}

/* Utilities */
.text-green { color: var(--success-color); }
.text-red { color: var(--danger-color); }
.text-muted { color: var(--secondary-color); font-size: 0.9rem; }

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

/* List Styles */
.customer-list {
    list-style: none;
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.customer-list li {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.customer-list li:active {
    background-color: #f3f4f6;
}

.port-num {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-right: 10px;
    min-width: 50px;
    text-align: center;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: auto;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-error { background-color: var(--danger-color); }

/* Desktop Tweaks */
@media (min-width: 768px) {
    .info-panel {
        width: 400px;
        right: 20px;
        left: auto;
        bottom: 20px;
        border-radius: 12px;
        transform: translateY(110%);
        max-height: 80vh;
    }
    
    .fab {
        right: 440px; /* Move left of panel */
    }

    .navbar {
        padding: 10px 30px;
    }
}
