/* Dashboard Styles */

/* Variables */
:root {
    --dashboard-primary: #2563eb;
    --dashboard-success: #10b981;
    --dashboard-warning: #f59e0b;
    --dashboard-info: #06b6d4;
    --dashboard-danger: #ef4444;
    --dashboard-bg: #f8fafc;
    --dashboard-card-bg: #ffffff;
    --dashboard-text: #1e293b;
    --dashboard-text-muted: #64748b;
    --dashboard-border: #e2e8f0;
    --dashboard-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --dashboard-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Dark Theme */
[data-theme="dark"] {
    --dashboard-bg: #0f172a;
    --dashboard-card-bg: #1e293b;
    --dashboard-text: #f1f5f9;
    --dashboard-text-muted: #94a3b8;
    --dashboard-border: #334155;
}

/* Base Styles */
body {
    background-color: var(--dashboard-bg);
    color: var(--dashboard-text);
    font-family: 'Cairo', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.dashboard-header {
    background: linear-gradient(135deg, var(--dashboard-primary) 0%, #1d4ed8 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: var(--dashboard-shadow-lg);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-section h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-section p {
    margin: 0.5rem 0 0 0;
    opacity: 0.9;
    font-size: 1rem;
}

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

.date-range-selector select {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.date-range-selector select:hover {
    background: rgba(255, 255, 255, 0.2);
}

.refresh-btn, .back-btn {
    padding: 0.5rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.5rem;
    background: transparent;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.refresh-btn:hover, .back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

/* Main Content */
.dashboard-main {
    padding: 2rem 0;
}

/* Stats Section */
.stats-section {
    margin-bottom: 3rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--dashboard-card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--dashboard-shadow);
    border: 1px solid var(--dashboard-border);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--dashboard-primary);
    transition: all 0.3s ease;
}

.stat-card.primary::before { background: var(--dashboard-primary); }
.stat-card.success::before { background: var(--dashboard-success); }
.stat-card.warning::before { background: var(--dashboard-warning); }
.stat-card.info::before { background: var(--dashboard-info); }

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--dashboard-shadow-lg);
}

.stat-card .stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    background: rgba(37, 99, 235, 0.1);
    color: var(--dashboard-primary);
}

.stat-card.success .stat-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--dashboard-success);
}

.stat-card.warning .stat-icon {
    background: rgba(245, 158, 11, 0.1);
    color: var(--dashboard-warning);
}

.stat-card.info .stat-icon {
    background: rgba(6, 182, 212, 0.1);
    color: var(--dashboard-info);
}

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--dashboard-text);
}

.stat-content p {
    margin: 0;
    color: var(--dashboard-text-muted);
    font-size: 0.9rem;
}

.stat-change {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.stat-change.positive {
    background: rgba(16, 185, 129, 0.1);
    color: var(--dashboard-success);
}

.stat-change.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--dashboard-danger);
}

/* Charts Section */
.charts-section {
    margin-bottom: 3rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.chart-card {
    background: var(--dashboard-card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--dashboard-shadow);
    border: 1px solid var(--dashboard-border);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.chart-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--dashboard-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-controls {
    display: flex;
    gap: 0.5rem;
}

.chart-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--dashboard-border);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--dashboard-text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chart-btn.active,
.chart-btn:hover {
    background: var(--dashboard-primary);
    color: white;
    border-color: var(--dashboard-primary);
}

.chart-container {
    position: relative;
    height: 300px;
}

/* Tables Section */
.tables-section {
    margin-bottom: 3rem;
}

.tables-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.table-card {
    background: var(--dashboard-card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--dashboard-shadow);
    border: 1px solid var(--dashboard-border);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.table-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--dashboard-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-all-btn {
    color: var(--dashboard-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.view-all-btn:hover {
    text-decoration: underline;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--dashboard-border);
}

table th {
    background: rgba(37, 99, 235, 0.05);
    font-weight: 600;
    color: var(--dashboard-text);
    font-size: 0.9rem;
}

table td {
    color: var(--dashboard-text-muted);
    font-size: 0.9rem;
}

table tbody tr:hover {
    background: rgba(37, 99, 235, 0.02);
}

/* Activity List */
.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--dashboard-border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.1);
    color: var(--dashboard-primary);
    font-size: 0.9rem;
}

.activity-content {
    flex: 1;
}

.activity-content h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dashboard-text);
}

.activity-content p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--dashboard-text-muted);
}

.activity-time {
    font-size: 0.8rem;
    color: var(--dashboard-text-muted);
}

/* Actions Section */
.actions-section {
    margin-bottom: 3rem;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.action-card {
    background: var(--dashboard-card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--dashboard-shadow);
    border: 1px solid var(--dashboard-border);
    text-align: center;
    transition: all 0.3s ease;
}

.action-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--dashboard-shadow-lg);
}

.action-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
    background: rgba(37, 99, 235, 0.1);
    color: var(--dashboard-primary);
}

.action-card h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dashboard-text);
}

.action-card p {
    margin: 0 0 1.5rem 0;
    color: var(--dashboard-text-muted);
    font-size: 0.9rem;
}

.action-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

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

.action-btn.secondary {
    background: var(--dashboard-text-muted);
    color: white;
}

.action-btn.success {
    background: var(--dashboard-success);
    color: white;
}

.action-btn.info {
    background: var(--dashboard-info);
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--dashboard-shadow);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.loading-spinner {
    background: var(--dashboard-card-bg);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--dashboard-shadow-lg);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--dashboard-border);
    border-top: 4px solid var(--dashboard-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--dashboard-card-bg);
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--dashboard-shadow-lg);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--dashboard-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--dashboard-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dashboard-text-muted);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 1.5rem;
}

.date-inputs {
    display: grid;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dashboard-text);
}

.input-group input {
    padding: 0.75rem;
    border: 1px solid var(--dashboard-border);
    border-radius: 0.5rem;
    background: var(--dashboard-card-bg);
    color: var(--dashboard-text);
    font-size: 0.9rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--dashboard-border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.btn.btn-secondary {
    background: var(--dashboard-text-muted);
    color: white;
}

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

/* Enhanced Responsive Design */

/* Extra Small devices (phones, 576px and down) */
@media (max-width: 575.98px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .dashboard-header {
        padding: 1rem 0;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .logo-section h1 {
        font-size: 1.5rem;
    }
    
    .header-actions {
        width: 100%;
        justify-content: center;
    }
    
    .date-range-selector select {
        width: 100%;
        max-width: 200px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
        text-align: center;
    }
    
    .stat-content h3 {
        font-size: 1.5rem;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .chart-card {
        padding: 1rem;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .chart-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .tables-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .table-card {
        padding: 1rem;
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    table {
        min-width: 300px;
    }
    
    .actions-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .action-card {
        padding: 1rem;
    }
    
    .action-btn {
        padding: 1rem;
        font-size: 0.9rem;
        min-height: 48px;
    }
    
    .dashboard-main {
        padding: 1rem 0;
    }
    
    /* Modal adjustments for mobile */
    .modal-content {
        margin: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
        max-width: none;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container {
        padding: 0 1rem;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .tables-grid {
        grid-template-columns: 1fr;
    }
    
    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .dashboard-main {
        padding: 1.5rem 0;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .chart-container {
        height: 350px;
    }
    
    .tables-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .actions-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .actions-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .tables-grid {
        grid-template-columns: 2fr 1fr;
        gap: 2rem;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1200px;
        margin: 0 auto;
    }
    
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .action-btn,
    .btn,
    .chart-btn,
    .refresh-btn,
    .back-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1rem;
    }
    
    .stat-card:hover,
    .chart-card:hover,
    .action-card:hover {
        transform: none;
    }
    
    /* Larger tap targets */
    .modal-close {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .dashboard-header {
        padding: 0.5rem 0;
    }
    
    .stats-grid {
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }
}

/* Print styles */
@media print {
    .header-actions,
    .actions-section,
    .loading-overlay,
    .modal {
        display: none !important;
    }
    
    .container {
        padding: 0;
    }
    
    .stat-card,
    .chart-card,
    .table-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .charts-grid,
    .stats-grid {
        break-inside: avoid;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .stat-card,
    .chart-card,
    .table-card,
    .action-card {
        border: 2px solid var(--dashboard-text);
    }
    
    .stat-change.positive {
        color: #008000;
    }
    
    .stat-change.negative {
        color: #ff0000;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .stat-card,
    .chart-card,
    .table-card,
    .action-card,
    .modal {
        transition: none;
        animation: none;
    }
    
    .fade-in,
    .slide-up {
        animation: none;
        opacity: 1;
        transform: none;
    }
    
    .spinner {
        animation: none;
    }
}

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

.slide-up {
    animation: slideUp 0.5s ease-out;
}

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

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