/* Unified Design System - Cohesive Color Scheme & Readability */

/* Global Color Variables */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --warning-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --info-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --light-bg: rgba(255, 255, 255, 0.95);
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --hover-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    --border-radius: 15px;
    --text-dark: #2d3748;
    --text-light: #718096;
    --text-white: #ffffff;
}

/* Body and Background */
body {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    color: var(--text-dark);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Card Base Styling */
.card, .stats-card, .analytics-card, .insights-card, .ai-summary-card, .form-card {
    background: var(--light-bg) !important;
    border: none !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--card-shadow) !important;
    transition: all 0.3s ease !important;
    color: var(--text-dark) !important;
    position: relative;
    overflow: hidden;
}

.card::before, .stats-card::before, .analytics-card::before, 
.insights-card::before, .ai-summary-card::before, .form-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.card:hover, .stats-card:hover, .analytics-card:hover, 
.insights-card:hover, .ai-summary-card:hover {
    transform: translateY(-5px) !important;
    box-shadow: var(--hover-shadow) !important;
}

/* Statistics Cards - Readable with Beautiful Backgrounds */
.stats-card {
    background: var(--light-bg) !important;
    color: var(--text-dark) !important;
    border: 2px solid transparent !important;
    background-clip: padding-box !important;
    height: 140px !important;
    display: flex !important;
    align-items: center !important;
}

.stats-card::before {
    background: var(--primary-gradient) !important;
}

.stats-card:nth-child(2)::before {
    background: var(--success-gradient) !important;
}

.stats-card:nth-child(3)::before {
    background: var(--warning-gradient) !important;
}

.stats-card:nth-child(4)::before {
    background: var(--info-gradient) !important;
}

.stats-card h3, .stats-card h4, .stats-card h5, .stats-card p {
    color: var(--text-dark) !important;
    font-weight: 600 !important;
}

.stats-card .card-title {
    color: var(--text-light) !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
}

/* Card Headers */
.card-header {
    background: var(--primary-gradient) !important;
    color: var(--text-white) !important;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
    border: none !important;
    padding: 20px 25px !important;
    font-weight: 600 !important;
}

.card-body {
    background: var(--light-bg) !important;
    color: var(--text-dark) !important;
    padding: 25px !important;
    border-radius: 0 0 var(--border-radius) var(--border-radius) !important;
}

/* Navigation - Consistent with Theme */
.navbar {
    background: var(--primary-gradient) !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1) !important;
    border: none !important;
}

.navbar-brand, .nav-link {
    color: var(--text-white) !important;
    font-weight: 500 !important;
}

.nav-link:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Buttons - Consistent Styling */
.btn-primary {
    background: var(--primary-gradient) !important;
    border: none !important;
    border-radius: 10px !important;
    color: var(--text-white) !important;
    font-weight: 500 !important;
    padding: 10px 20px !important;
    transition: all 0.3s ease !important;
}

.btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3) !important;
    color: var(--text-white) !important;
}

.btn-success {
    background: var(--success-gradient) !important;
    border: none !important;
    border-radius: 10px !important;
    color: var(--text-white) !important;
    font-weight: 500 !important;
}

.btn-warning {
    background: var(--warning-gradient) !important;
    border: none !important;
    border-radius: 10px !important;
    color: var(--text-dark) !important;
    font-weight: 500 !important;
}

.btn-info {
    background: var(--info-gradient) !important;
    border: none !important;
    border-radius: 10px !important;
    color: var(--text-dark) !important;
    font-weight: 500 !important;
}

/* Forms - Readable and Beautiful */
.form-control {
    background: var(--light-bg) !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 10px !important;
    color: var(--text-dark) !important;
    padding: 12px 15px !important;
    transition: all 0.3s ease !important;
}

.form-control:focus {
    border-color: #667eea !important;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.15) !important;
    background: var(--light-bg) !important;
    color: var(--text-dark) !important;
}

.form-label {
    color: var(--text-dark) !important;
    font-weight: 600 !important;
    margin-bottom: 8px !important;
}

.form-text {
    color: var(--text-light) !important;
    font-size: 0.875rem !important;
}

/* Tables - Enhanced Readability */
.table {
    background: var(--light-bg) !important;
    border-radius: var(--border-radius) !important;
    overflow: hidden !important;
    box-shadow: var(--card-shadow) !important;
    color: var(--text-dark) !important;
}

.table thead {
    background: var(--primary-gradient) !important;
    color: var(--text-white) !important;
}

.table thead th {
    color: var(--text-white) !important;
    border: none !important;
    padding: 15px !important;
    font-weight: 600 !important;
}

.table tbody tr {
    background: var(--light-bg) !important;
    border: none !important;
    transition: all 0.3s ease !important;
}

.table tbody tr:hover {
    background: rgba(102, 126, 234, 0.05) !important;
    transform: translateX(3px) !important;
}

.table tbody td {
    border: none !important;
    padding: 12px 15px !important;
    color: var(--text-dark) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
}

/* Badges - Consistent with Theme */
.badge {
    padding: 6px 12px !important;
    border-radius: 20px !important;
    font-weight: 500 !important;
    font-size: 0.75rem !important;
}

.bg-success {
    background: var(--success-gradient) !important;
    color: var(--text-white) !important;
}

.bg-warning {
    background: var(--warning-gradient) !important;
    color: var(--text-dark) !important;
}

.bg-danger {
    background: var(--secondary-gradient) !important;
    color: var(--text-white) !important;
}

.bg-info {
    background: var(--info-gradient) !important;
    color: var(--text-dark) !important;
}

.bg-primary {
    background: var(--primary-gradient) !important;
    color: var(--text-white) !important;
}

/* Alerts - Readable and Styled */
.alert {
    border: none !important;
    border-radius: var(--border-radius) !important;
    border-left: 4px solid !important;
    font-weight: 500 !important;
}

.alert-info {
    background: rgba(102, 126, 234, 0.1) !important;
    border-left-color: #667eea !important;
    color: var(--text-dark) !important;
}

.alert-success {
    background: rgba(67, 233, 123, 0.1) !important;
    border-left-color: #43e97b !important;
    color: var(--text-dark) !important;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1) !important;
    border-left-color: #ffc107 !important;
    color: var(--text-dark) !important;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1) !important;
    border-left-color: #dc3545 !important;
    color: var(--text-dark) !important;
}

/* Dropdown Menus */
.dropdown-menu {
    border: none !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--card-shadow) !important;
    background: var(--light-bg) !important;
}

.dropdown-item {
    color: var(--text-dark) !important;
    border-radius: 8px !important;
    margin: 3px 8px !important;
    transition: all 0.3s ease !important;
}

.dropdown-item:hover {
    background: rgba(102, 126, 234, 0.1) !important;
    color: var(--text-dark) !important;
}

/* Pagination */
.pagination .page-link {
    border: none !important;
    border-radius: 8px !important;
    margin: 0 2px !important;
    background: var(--light-bg) !important;
    color: var(--text-dark) !important;
    transition: all 0.3s ease !important;
}

.pagination .page-link:hover {
    background: rgba(102, 126, 234, 0.1) !important;
    color: var(--text-dark) !important;
}

.pagination .page-item.active .page-link {
    background: var(--primary-gradient) !important;
    color: var(--text-white) !important;
}

/* Text Colors - Ensuring Readability */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-dark) !important;
    font-weight: 600 !important;
}

p, span, div {
    color: var(--text-dark) !important;
}

.text-muted {
    color: var(--text-light) !important;
}

.text-white {
    color: var(--text-white) !important;
}

/* Chart Containers */
.chart-container {
    background: var(--light-bg) !important;
    border-radius: var(--border-radius) !important;
    padding: 20px !important;
    box-shadow: var(--card-shadow) !important;
}

/* Modal Enhancements */
.modal-content {
    border: none !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--hover-shadow) !important;
}

.modal-header {
    background: var(--primary-gradient) !important;
    color: var(--text-white) !important;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
    border: none !important;
}

.modal-body {
    background: var(--light-bg) !important;
    color: var(--text-dark) !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .card, .stats-card, .analytics-card, .insights-card, .ai-summary-card, .form-card {
        margin-bottom: 20px !important;
    }
    
    .card-body {
        padding: 20px !important;
    }
    
    .card-header {
        padding: 15px 20px !important;
    }
}

/* Animation Classes */
.floating-element {
    animation: gentleFloat 6s ease-in-out infinite !important;
}

@keyframes gentleFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

/* Override any conflicting dark theme styles */
.card-body, .table tbody td, .form-control, .dropdown-menu {
    background: var(--light-bg) !important;
    color: var(--text-dark) !important;
}

/* Ensure icons remain visible */
.fas, .far, .fab {
    color: inherit !important;
}

/* Progress bars */
.progress {
    background: rgba(233, 236, 239, 0.3) !important;
    border-radius: 10px !important;
    height: 10px !important;
}

.progress-bar {
    background: var(--primary-gradient) !important;
    border-radius: 10px !important;
}

/* Specific text color fixes for analytics */
.ai-summary-card .text-dark, .ai-summary-card strong {
    color: var(--text-dark) !important;
}

.ai-summary-card .text-success {
    color: #28a745 !important;
}

.ai-summary-card .text-primary {
    color: #007bff !important;
}

.ai-summary-card .text-warning {
    color: #ffc107 !important;
}

.ai-summary-card .text-danger {
    color: #dc3545 !important;
}

.ai-summary-card .text-muted {
    color: var(--text-light) !important;
}

/* Insights card text visibility */
.insights-card h4, .insights-card h5, .insights-card p, .insights-card span, .insights-card strong {
    color: var(--text-dark) !important;
}

.insights-card .text-primary {
    color: #007bff !important;
}

.insights-card .text-success {
    color: #28a745 !important;
}

/* Trend cards text visibility */
.trend-card h4, .trend-card h5, .trend-card p, .trend-card span {
    color: var(--text-dark) !important;
}

.morning-card, .night-card {
    color: var(--text-dark) !important;
}

.morning-card h4, .morning-card h5, .morning-card p, .morning-card span,
.night-card h4, .night-card h5, .night-card p, .night-card span {
    color: var(--text-dark) !important;
}

/* Filter section text */
.filter-group label, .filter-group .form-label {
    color: var(--text-dark) !important;
    font-weight: 600 !important;
}

/* Chart section text */
.chart-container h5, .chart-container p, .chart-container span {
    color: var(--text-dark) !important;
}

/* Override Bootstrap dark theme text colors */
body[data-bs-theme="dark"] .card-body,
body[data-bs-theme="dark"] .table tbody td,
body[data-bs-theme="dark"] .form-control,
body[data-bs-theme="dark"] .dropdown-menu {
    color: var(--text-dark) !important;
}

/* Ensure all headings are visible */
body[data-bs-theme="dark"] h1, 
body[data-bs-theme="dark"] h2, 
body[data-bs-theme="dark"] h3, 
body[data-bs-theme="dark"] h4, 
body[data-bs-theme="dark"] h5, 
body[data-bs-theme="dark"] h6 {
    color: var(--text-dark) !important;
}

/* Force all paragraph and span text to be visible */
body[data-bs-theme="dark"] .card p,
body[data-bs-theme="dark"] .card span,
body[data-bs-theme="dark"] .card div {
    color: var(--text-dark) !important;
}

/* Footer and bottom text readability fixes */
.footer, .footer-text, .privacy-link {
    background: var(--light-bg) !important;
    color: var(--text-dark) !important;
    padding: 20px !important;
    border-radius: var(--border-radius) !important;
    margin-top: 30px !important;
}

.footer a, .privacy-link a {
    color: #007bff !important;
    text-decoration: none !important;
}

.footer a:hover, .privacy-link a:hover {
    color: #0056b3 !important;
    text-decoration: underline !important;
}

/* Export buttons styling */
.btn-outline-secondary {
    background: var(--light-bg) !important;
    border: 2px solid #667eea !important;
    color: #667eea !important;
    border-radius: 10px !important;
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
}

.btn-outline-secondary:hover {
    background: var(--primary-gradient) !important;
    border-color: #667eea !important;
    color: var(--text-white) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3) !important;
}

/* Dropdown toggle buttons */
.dropdown-toggle {
    background: var(--light-bg) !important;
    border: 2px solid #667eea !important;
    color: #667eea !important;
    border-radius: 10px !important;
    font-weight: 500 !important;
}

.dropdown-toggle:hover {
    background: var(--primary-gradient) !important;
    color: var(--text-white) !important;
    border-color: #667eea !important;
}