/* Tailwind CSS will be loaded via external script in app.py */

/* Custom styles for UGEP Progress Curve Dashboard */

/* ── Skeleton / loading animations ── */
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes loading-bar-slide {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

:root {
    --primary-color: #0066cc;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
}

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

html, body {
    background-color: #ffffff;
    height: 100%;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

#__primary-layout {
    background-color: #ffffff;
}

/* ==================== Header Styles ==================== */
.navbar {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    height: 64px;
    display: flex;
    align-items: center;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: #333 !important;
}

.navbar img {
    height: 40px;
    object-fit: contain;
}

/* ==================== Sidebar Styles ==================== */
.sidebar {
    background-color: #f8f9fa;
    border-right: 1px solid #e9ecef;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    display: none;
}

.sidebar .nav-link {
    padding: 0.75rem 1rem;
    color: #333 !important;
    border-left: 3px solid transparent;
    margin: 0.25rem 0;
    transition: all 0.2s ease;
    font-weight: 500;
}

.sidebar .nav-link:hover {
    background-color: #e9ecef;
    border-left-color: var(--primary-color);
    transform: translateX(4px);
}

.sidebar .nav-link.active {
    background-color: #e7f1ff;
    color: var(--primary-color) !important;
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.sidebar .nav-link i {
    width: 18px;
    text-align: center;
}

.sidebar-close-btn {
    display: none;
}

/* ==================== Main Content ==================== */
#page-content {
    background-color: #ffffff;
    min-height: calc(100vh - 64px);
}

/* ==================== Card Styles ==================== */
.card {
    border: 1px solid #e9ecef;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    background-color: #ffffff;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    border-color: #dee2e6;
}

.card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #f0f2f5 100%);
    border-bottom: 2px solid var(--primary-color);
    font-weight: 600;
    color: #333;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.25rem;
    background-color: #ffffff;
}

/* ==================== Badge & Pill Styles ==================== */
.badge {
    font-weight: 500;
    padding: 0.4em 0.8em;
    border-radius: 0.5rem;
}

.badge-primary {
    background-color: #0066cc;
    color: white;
}

/* ==================== Button Styles ==================== */
.btn {
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    border: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

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

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

.btn-primary:hover {
    background-color: #004fa3;
}

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

.btn-outline-danger:hover {
    background-color: var(--danger-color);
    color: white;
}

/* ==================== Form Controls ==================== */
.form-control, .form-select {
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* ==================== Table Styles ==================== */
.table {
    font-size: 13px;
    margin-bottom: 0;
}

.table thead {
    background-color: #f8f9fa;
    border-color: #e9ecef;
}

.table thead th {
    font-weight: 600;
    padding: 0.75rem;
    color: #333;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.table tbody td {
    padding: 0.625rem 0.75rem;
    border-color: #e9ecef;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

.dash-table-container {
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.dash-table-container .dash-spreadsheet-container {
    max-height: 700px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
}

.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 10;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
}

/* ==================== Dropdown Styles ==================== */
.Select-menu-outer {
    z-index: 9999 !important;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* ==================== Plotly Chart ==================== */
.js-plotly-plot {
    border-radius: 0.75rem;
}

.plotly {
    background-color: #ffffff;
}

/* ==================== Loading Spinner ==================== */
._dash-loading {
    margin: 2rem auto;
    color: #3b82f6;
}

/* Loading overlay for better visibility */
._dash-loading::after {
    display: block;
    content: "Loading...";
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    margin-top: 0.5rem;
}

/* Spinner animation */
._dash-loading-callback {
    position: relative;
    display: inline-block;
}

/* Add pulse animation to loading containers */
.dash-spinner {
    animation: dash-pulse 1.5s ease-in-out infinite;
}

@keyframes dash-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Loading state for dropdowns */
.Select--is-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Custom loading overlay for content areas */
.content-loading {
    position: relative;
    min-height: 200px;
}

.content-loading::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== Toast Notification ==================== */
.toast {
    border: 1px solid #e9ecef;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background-color: #ffffff;
}

.toast-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
}

.toast-body {
    padding: 1rem;
}

/* ==================== Responsive Design ==================== */
@media (min-width: 992px) {
    .sidebar {
        display: block !important;
        width: 220px;
        position: fixed;
        left: 0;
        top: 64px;
        height: calc(100vh - 64px);
        border-radius: 0;
        z-index: 900;
        background-color: #f8f9fa;
    }

    #page-content {
        margin-left: 220px;
        margin-top: 64px;
        width: calc(100% - 220px);
    }

    .navbar-toggler {
        display: none;
    }
}

@media (max-width: 991px) {
    .sidebar {
        width: 100%;
        position: fixed;
        left: 0;
        top: 64px;
        height: calc(100vh - 64px);
        border-radius: 0;
        z-index: 1050;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
        background-color: #f8f9fa;
        border-right: 1px solid #e9ecef;
        border-bottom: none;
    }

    .sidebar.d-none {
        display: none !important;
    }

    #page-content {
        margin-left: 0;
        margin-top: 64px;
        width: 100%;
    }

    .container-fluid {
        padding: 1rem;
    }

    .card {
        margin-bottom: 0.75rem;
    }
}

/* ==================== Utilities ==================== */
.text-muted {
    color: #6c757d !important;
}

.small {
    font-size: 0.875rem;
}

.fw-bold {
    font-weight: 700 !important;
}

.fw-500 {
    font-weight: 500 !important;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.border-bottom {
    border-bottom: 1px solid #e9ecef !important;
}

.border-end {
    border-right: 1px solid #e9ecef !important;
}

/* ==================== Custom Color Inputs ==================== */
input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    cursor: pointer;
    padding: 4px;
}

input[type="color"]:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* ==================== Page Transitions ==================== */
#page-content {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ==================== Print Styles ==================== */
@media print {
    .sidebar,
    .navbar,
    button,
    .no-print {
        display: none !important;
    }

    #page-content {
        margin-left: 0 !important;
        margin-top: 0 !important;
    }
}

/* ==================== Accessibility ==================== */
.btn:focus,
.form-control:focus,
.form-select:focus,
.nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ==================== Scrollbar Customization ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}
