/* Bootstrap Theme Customizations for Analytics Platform */

/* Root CSS Variables for Theme Consistency */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    
    --sidebar-width: 280px;
    --sidebar-minimized-width: 70px;
    --header-height: 70px;
    --footer-height: 60px;
    
    --border-radius-lg: 12px;
    --border-radius-md: 8px;
    --border-radius-sm: 4px;
    
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

/* Body and Layout */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    line-height: 1.6;
}

/* Sidebar Styling */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    border-right: 1px solid #dee2e6;
    transition: all 0.3s ease;
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar Hidden State - Desktop */
@media (min-width: 769px) {
    .sidebar-hidden {
        transform: translateX(-100%);
    }
    
    .sidebar-hidden ~ .wrapper {
        margin-left: 0;
    }
    
    .sidebar-hidden + .main-content {
        margin-left: 0;
    }
}

/* Mobile Responsive - Sidebar hidden by default */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1055;
    }
    
    .sidebar-show {
        transform: translateX(0);
    }
    
    .wrapper {
        margin-left: 0;
    }
    
    .main-content {
        margin-left: 0;
    }
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

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

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

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

.sidebar-brand {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-brand .sidebar-brand-full {
    color: #ffffff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.sidebar-brand .sidebar-brand-minimized {
    display: none;
    color: #ffffff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

.sidebar-brand a:hover {
    color: #f8f9fa;
}

/* Sidebar Toggler Button */
.sidebar-toggler {
    position: absolute;
    top: 50%;
    right: -15px;
    width: 30px;
    height: 30px;
    background: var(--primary-color);
    border: 2px solid #ffffff;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    cursor: pointer;
    transform: translateY(-50%);
    z-index: 1051;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggler:hover {
    background: #0056b3;
    transform: translateY(-50%) scale(1.1);
}

.sidebar-minimized .sidebar-toggler i {
    transform: rotate(180deg);
}

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

.sidebar-nav .nav-group-header {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1.5rem 0.5rem;
    margin-top: 1rem;
}

.sidebar-nav .nav-group-header:first-child {
    margin-top: 0;
}

.sidebar-nav .nav-item {
    margin-bottom: 0.25rem;
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    border: none;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
    position: relative;
}

.sidebar-nav .nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-nav .nav-link.active {
    color: #ffffff;
    background-color: var(--primary-color);
    border-left: 3px solid #ffffff;
}

.sidebar-nav .nav-link i {
    width: 20px;
    margin-right: 0.75rem;
    font-size: 1rem;
}

/* Sidebar Toggle States */
.sidebar-minimized {
    width: var(--sidebar-minimized-width);
}

.sidebar-minimized .sidebar-brand-full {
    display: none;
}

.sidebar-minimized .sidebar-brand-minimized {
    display: block;
}

.sidebar-minimized .nav-link span:not(.nav-icon),
.sidebar-minimized .nav-title,
.sidebar-minimized .nav-group-toggle::after {
    display: none;
}

.sidebar-minimized .nav-link {
    padding: 0.75rem;
    justify-content: center;
}

.sidebar-minimized .nav-link i,
.sidebar-minimized .nav-link .nav-icon {
    margin-right: 0;
}

.sidebar-minimized .nav-group-items {
    display: none !important;
}

/* Mobile sidebar show state */
.sidebar-show {
    transform: translateX(0);
}

/* Main Content Area - Updated to work with .wrapper class */
.wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-minimized ~ .wrapper {
    margin-left: var(--sidebar-minimized-width);
}

/* Legacy support for main-content class */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-minimized + .main-content {
    margin-left: var(--sidebar-minimized-width);
}

/* Header Styling */
.header {
    background: #ffffff;
    border-bottom: 1px solid #dee2e6;
    padding: 0 1.5rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1040;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-nav .btn {
    border: none;
    background: none;
    color: #6c757d;
    padding: 0.5rem;
    border-radius: var(--border-radius-md);
}

.header-nav .btn:hover {
    background-color: #f8f9fa;
    color: #212529;
}

/* Content Area */
.content {
    flex: 1;
    padding: 2rem;
    background-color: #f8f9fa;
}

/* Card Enhancements */
.card {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    background-color: #ffffff;
    border-bottom: 1px solid #e9ecef;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0 !important;
    padding: 1.25rem 1.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* Gradient Card Headers */
.card-header.bg-gradient {
    color: #ffffff;
    border: none;
}

/* Button Enhancements */
.btn {
    border-radius: var(--border-radius-md);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Badge Enhancements */
.badge {
    border-radius: var(--border-radius-sm);
    padding: 0.375rem 0.75rem;
    font-weight: 500;
}

/* Table Enhancements */
.table {
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.table thead th {
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
    background-color: #f8f9fa;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Alert Enhancements */
.alert {
    border-radius: var(--border-radius-md);
    border: none;
    padding: 1rem 1.25rem;
}

.alert-info {
    background-color: rgba(13, 202, 240, 0.1);
    color: #055160;
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #664d03;
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: #721c24;
}

/* Form Enhancements */
.form-control {
    border-radius: var(--border-radius-md);
    border: 1px solid #ced4da;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Footer */
.footer {
    background-color: #ffffff;
    border-top: 1px solid #dee2e6;
    padding: 1rem 0;
    margin-top: auto;
}

/* Responsive Design */
@media (max-width: 576px) {
    .content {
        padding: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: var(--border-radius-md) !important;
        margin-bottom: 0.25rem;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@media (max-width: 768px) {
    .header-toggler {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .sidebar {
        transform: translateX(0);
    }
    
    .header-toggler {
        display: none;
    }
}

/* Loading Spinner */
.spinner-custom {
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(13, 110, 253, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Utility Classes */
.text-gradient {
    background: linear-gradient(45deg, var(--primary-color), var(--info-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #4c84ff 100%);
}

.bg-gradient-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #20c997 100%);
}

.bg-gradient-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #fd7e14 100%);
}

.bg-gradient-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #e83e8c 100%);
}

.bg-gradient-info {
    background: linear-gradient(135deg, var(--info-color) 0%, #6f42c1 100%);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --light-color: #212529;
        --dark-color: #f8f9fa;
    }
    
    body {
        background-color: #1a1a1a;
        color: #f8f9fa;
    }
    
    .card {
        background-color: #2d3748;
        color: #f8f9fa;
    }
    
    .header {
        background-color: #2d3748;
        border-bottom-color: #4a5568;
    }
    
    .footer {
        background-color: #2d3748;
        border-top-color: #4a5568;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .header,
    .footer {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .content {
        padding: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}
