/**
 * Dashboard Styles - Pizza System
 * Стилі для головної сторінки Dashboard
 */

/* ==========================================
   Dashboard Layout
   ========================================== */

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

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.dashboard-header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: #2c3e50;
}

.dashboard-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ==========================================
   KPI Cards Grid
   ========================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid var(--kpi-color, #3498db);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.kpi-card.primary { --kpi-color: #3498db; }
.kpi-card.success { --kpi-color: #27ae60; }
.kpi-card.danger { --kpi-color: #e74c3c; }
.kpi-card.warning { --kpi-color: #f39c12; }
.kpi-card.info { --kpi-color: #17a2b8; }

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--kpi-color, #2c3e50);
    line-height: 1.2;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 8px;
}

.kpi-trend {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-trend.positive {
    color: #27ae60;
}

.kpi-trend.negative {
    color: #e74c3c;
}

.kpi-trend.neutral {
    color: #7f8c8d;
}

/* ==========================================
   Dashboard Grid (2 columns)
   ========================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.dashboard-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.section-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.section-header .badge {
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
}

/* Week Navigation */
.week-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.week-nav-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.week-nav-btn:hover {
    background: rgba(255,255,255,0.35);
    transform: scale(1.1);
}

.week-nav-btn:active {
    transform: scale(0.95);
}

#week-period-label {
    font-size: 0.95rem;
    font-weight: 500;
    min-width: 140px;
    text-align: center;
}

.section-content {
    padding: 16px 20px;
    max-height: 400px;
    overflow-y: auto;
}

/* ==========================================
   Dashboard Tables
   ========================================== */

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.dashboard-table th {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 2px solid #ecf0f1;
    color: #7f8c8d;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.dashboard-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #ecf0f1;
    vertical-align: middle;
}

.dashboard-table tr:last-child td {
    border-bottom: none;
}

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

/* Row colors for orders */
.dashboard-table tr.overdue {
    background: #fdecea;
}

.dashboard-table tr.overdue:hover {
    background: #fad4cf;
}

.dashboard-table tr.urgent {
    background: #fef9e7;
}

.dashboard-table tr.urgent:hover {
    background: #fef3cd;
}

.dashboard-table tr.ready {
    background: #e8f8f5;
}

.dashboard-table tr.ready:hover {
    background: #d4efdf;
}

/* ==========================================
   Status Badges
   ========================================== */

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.new {
    background: #e8f4fd;
    color: #2980b9;
}

.status-badge.collecting {
    background: #fef9e7;
    color: #d68910;
}

.status-badge.ready {
    background: #e8f8f5;
    color: #1e8449;
}

.status-badge.shipped {
    background: #ebdef0;
    color: #7d3c98;
}

.status-badge.completed {
    background: #d5dbdb;
    color: #566573;
}

/* Priority badges */
.priority-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.priority-badge.urgent {
    background: #e74c3c;
    color: white;
}

.priority-badge.high {
    background: #f39c12;
    color: white;
}

.priority-badge.medium {
    background: #3498db;
    color: white;
}

.priority-badge.low {
    background: #95a5a6;
    color: white;
}

/* ==========================================
   Week Timeline
   ========================================== */

.week-timeline {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    padding: 8px;
}

.day-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.day-card.today {
    border-color: #3498db;
    background: #e8f4fd;
}

.day-card.has-plan {
    background: #e8f8f5;
}

.day-card.load-low {
    background: #d4efdf;
    border-color: #27ae60;
}

.day-card.load-medium {
    background: #fef9e7;
    border-color: #f39c12;
}

.day-card.load-high {
    background: #fdecea;
    border-color: #e74c3c;
}

.day-name {
    font-size: 0.75rem;
    color: #7f8c8d;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.day-date {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.day-quantity {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2c3e50;
}

.day-capacity {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 4px;
}

/* ==========================================
   Charts Section
   ========================================== */

.chart-container {
    position: relative;
    height: 280px;
    padding: 16px;
}

/* Clients chart needs more width for labels */
#clients-chart {
    width: 100% !important;
}

.chart-title {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 12px;
    text-align: center;
}

/* ==========================================
   Quick Actions
   ========================================== */

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #f8f9fa;
    border: 1px solid #ecf0f1;
    border-radius: 10px;
    color: #2c3e50;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.quick-action-btn:hover {
    background: #e8f4fd;
    border-color: #3498db;
    transform: translateX(4px);
}

.quick-action-btn .icon {
    font-size: 1.3rem;
}

.quick-action-btn .text {
    flex: 1;
}

.quick-action-btn .arrow {
    color: #bdc3c7;
}

/* ==========================================
   Empty States
   ========================================== */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #7f8c8d;
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state .message {
    font-size: 0.95rem;
}

/* ==========================================
   Loading State
   ========================================== */

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.loading-spinner::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid #ecf0f1;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==========================================
   Full Width Section
   ========================================== */

.dashboard-full-width {
    margin-bottom: 24px;
}

/* ==========================================
   Responsive Design
   ========================================== */

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: 12px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .kpi-card {
        padding: 14px;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .week-timeline {
        grid-template-columns: repeat(4, 1fr);
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-content {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .week-timeline {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-table {
        font-size: 0.8rem;
    }

    .dashboard-table th,
    .dashboard-table td {
        padding: 8px 4px;
    }
}

/* ==========================================
   Revenue Comparison Section
   ========================================== */

.revenue-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 16px;
}

.revenue-period {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.revenue-period.current {
    background: #e8f4fd;
    border: 2px solid #3498db;
}

.revenue-period .period-label {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-bottom: 8px;
}

.revenue-period .period-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #2c3e50;
}

.revenue-period .period-details {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 8px;
}

@media (max-width: 600px) {
    .revenue-comparison {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   Last Update Info
   ========================================== */

.last-update {
    text-align: center;
    padding: 12px;
    color: #7f8c8d;
    font-size: 0.85rem;
    border-top: 1px solid #ecf0f1;
    margin-top: 16px;
}

/* ==========================================
   Button Styles (extend main.css)
   ========================================== */

.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-refresh:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.btn-refresh.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-refresh.loading .icon {
    animation: spin 0.8s linear infinite;
}
