/* Modern Field Service Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - PoolControl Pro (Blue Theme) */
    --primary-color: #0077b6;       /* Medium Blue (Brand) */
    --primary-hover: #023e8a;       /* Dark Blue (Hover) */
    --secondary-color: #48cae4;     /* Light Cyan (Accent) */
    --accent-color: #90e0ef;        /* Pale Cyan */
    
    --success-color: #10b981;       /* Emerald 500 */
    --warning-color: #f59e0b;       /* Amber 500 */
    --danger-color: #ef4444;        /* Red 500 */
    --info-color: #00b4d8;          /* Bright Blue */

    /* Light Theme Defaults */
    --bg-body: #f0f9ff;             /* Alice Blue / Very Light Blue */
    --bg-surface: #ffffff;
    --text-main: #0f172a;           /* Slate 900 */
    --text-muted: #64748b;          /* Slate 500 */
    --border-color: #e2e8f0;        /* Slate 200 */
    
    /* Sidebar */
    --sidebar-bg: #0077b6;          /* Brand Blue */
    --sidebar-text: #ffffff;        /* White */
    --sidebar-active: #023e8a;      /* Dark Blue */
    --sidebar-width: 260px;
    --header-height: 64px;

    /* Spacing & Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
    --bg-body: #0f172a;             /* Slate 900 */
    --bg-surface: #1e293b;          /* Slate 800 */
    --text-main: #f8fafc;           /* Slate 50 */
    --text-muted: #94a3b8;          /* Slate 400 */
    --border-color: #334155;        /* Slate 700 */
    
    --sidebar-bg: #020617;          /* Slate 950 */
    --sidebar-active: #1e293b;      /* Slate 800 */
}

/* Base Styles */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.75rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* Layout Wrapper */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    min-height: 100vh;
}

/* Sidebar */
#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    transition: all 0.3s;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

@media (min-width: 769px) {
    #sidebar.active {
        min-width: 80px;
        max-width: 80px;
        margin-left: 0;
    }

    #sidebar.active .sidebar-header h3 span,
    #sidebar.active ul li a span,
    #sidebar.active .components li.small span {
        display: none;
    }

    #sidebar.active .sidebar-header h3 {
        justify-content: center;
    }

    #sidebar.active ul li a {
        justify-content: center;
        padding: 0.75rem 0.25rem;
    }

    #sidebar.active ul li a i {
        margin-right: 0;
        font-size: 1.4rem;
    }
}

.sidebar-header {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header h3 {
    color: #fff;
    font-size: 1.25rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#sidebar ul.components {
    padding: 1rem 0;
    flex-grow: 1;
    overflow-y: auto;
}

#sidebar ul li {
    padding: 0.25rem 1rem;
}

#sidebar ul li a {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    color: var(--sidebar-text);
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

#sidebar ul li a i {
    width: 24px;
    text-align: center;
    margin-right: 0.75rem;
    font-size: 1.1rem;
    opacity: 0.8;
}

#sidebar ul li a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

#sidebar ul li.active > a {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

#sidebar ul li.active > a i {
    opacity: 1;
}

/* Content Area */
#content {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
    flex: 1; /* Allow to fill remaining space */
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Navbar */
.navbar {
    background: var(--bg-surface) !important;
    height: var(--header-height);
    box-shadow: var(--shadow-sm);
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.navbar-btn {
    box-shadow: none;
    outline: none !important;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
    padding: 0.5rem;
}

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

/* Main Content */
.main-content {
    padding: 2rem;
    flex: 1;
    width: 100%;
    max-width: 1600px; /* Max width for large screens */
    margin: 0 auto;
}

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 1.5rem;
    color: var(--text-main);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

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

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

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

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: #fff;
}

/* Tables */
.table-responsive {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.table {
    margin-bottom: 0;
    background: var(--bg-surface);
    color: var(--text-main);
}

.table thead th {
    background: var(--bg-body);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    border-top: none;
}

.table tbody td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-main);
    font-size: 0.9rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 119, 182, 0.05); /* Very light brand blue */
}

/* Forms */
.form-control, .form-select {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-md);
    padding: 0.625rem 0.875rem;
    font-size: 0.95rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.15);
    background-color: var(--bg-surface);
    color: var(--text-main);
}

.form-label {
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* Alerts */
.alert {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* Utilities */
.text-muted { color: var(--text-muted) !important; }
.bg-light { background-color: var(--bg-body) !important; }
.bg-white { background-color: var(--bg-surface) !important; }

/* Dark Mode Specific Overrides for 3rd party components */
[data-theme="dark"] .dropdown-menu {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
}
[data-theme="dark"] .dropdown-item {
    color: var(--text-main);
}
[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--sidebar-active);
}
[data-theme="dark"] .modal-content {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
}
[data-theme="dark"] .close {
    color: var(--text-main);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
    }
    #sidebar.active {
        margin-left: 0;
    }
    .navbar {
        padding: 0 1rem;
    }
    .main-content {
        padding: 1rem;
    }
}

/* Status Badges */
.badge {
    padding: 0.5em 0.75em;
    font-weight: 600;
    border-radius: 9999px; /* Pill shape */
    letter-spacing: 0.025em;
}

/* Soft Backgrounds */
.bg-soft-primary { background-color: rgba(0, 119, 182, 0.1) !important; color: var(--primary-color) !important; }
.bg-soft-secondary { background-color: rgba(100, 116, 139, 0.1) !important; color: var(--secondary-color) !important; }
.bg-soft-success { background-color: rgba(16, 185, 129, 0.1) !important; color: var(--success-color) !important; }
.bg-soft-warning { background-color: rgba(245, 158, 11, 0.1) !important; color: var(--warning-color) !important; }
.bg-soft-danger { background-color: rgba(239, 68, 68, 0.1) !important; color: var(--danger-color) !important; }
.bg-soft-info { background-color: rgba(14, 165, 233, 0.1) !important; color: var(--accent-color) !important; }

/* Icon Shapes */
.icon-shape {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

/* Avatar */
.avatar-circle {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    object-fit: cover;
}

/* Animations & Effects */
.hover-card-effect:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md) !important;
    border-color: var(--primary-color) !important;
    background-color: var(--bg-surface) !important;
}

.pulse-animation {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent; 
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8; 
}

/* Utility to prevent animations on load */
.no-transition {
    transition: none !important;
}

/* Sidebar Submenu Styling */
#sidebar ul ul {
    background: rgba(0, 0, 0, 0.1);
}

#sidebar ul ul a {
    padding-left: 3rem !important;
    font-size: 0.9em;
}

#sidebar ul ul a:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Dropdown arrow adjustment */
#sidebar a[data-bs-toggle="collapse"] {
    position: relative;
}

#sidebar a[data-bs-toggle="collapse"]::after {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: .255em;
    vertical-align: .255em;
    content: "";
    border-top: .3em solid;
    border-right: .3em solid transparent;
    border-bottom: 0;
    border-left: .3em solid transparent;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s;
}

#sidebar a[aria-expanded="true"]::after {
    transform: translateY(-50%) rotate(-180deg);
}

/* Hide arrow when sidebar is collapsed */
@media (min-width: 769px) {
    #sidebar.active a[data-bs-toggle="collapse"]::after {
        display: none;
    }

    /* Fix submenu layout when collapsed */
    #sidebar.active ul ul a {
        padding: 0.8rem 0 !important;
        justify-content: center;
        margin: 0.2rem 0.5rem;
        border-radius: var(--radius-md);
    }
    
    #sidebar.active ul ul a i {
        margin-right: 0;
        font-size: 1.25rem;
    }
}