/* Analytics Dashboard Frontend Styles */

#analytics-dashboard {
    color: #333;
}

/* Header */
.analytics-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    text-align: center;
}

.analytics-header h1 {
    margin: 0 0 10px 0;
    font-size: 32px;
    font-weight: 700;
}

.analytics-subtitle {
    margin: 0;
    font-size: 16px;
    opacity: 0.9;
}

/* Date Picker */
.analytics-date-picker {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    align-items: center;
    flex-wrap: wrap;
}

.date-inputs {
    display: flex;
    gap: 15px;
}

.date-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.date-group label {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.date-group input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 150px;
    background: white;
}

.date-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.quick-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.quick-date-btn {
    padding: 8px 16px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    font-weight: 500;
}

.quick-date-btn:hover {
    background: #f5f5f5;
    border-color: #667eea;
}

.quick-date-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* KPI Cards */
.analytics-kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.kpi-card {
    display: flex;
    gap: 15px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.kpi-card.revenue {
    border-left-color: #2563eb;
}

.kpi-card.profit {
    border-left-color: #16a34a;
}

.kpi-card.orders {
    border-left-color: #ea580c;
}

.kpi-card.roi {
    border-left-color: #667eea;
}

.kpi-icon {
    font-size: 32px;
    line-height: 1;
    min-width: 40px;
}

.kpi-content {
    flex: 1;
}

.kpi-content h3 {
    margin: 0 0 5px 0;
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    margin: 5px 0;
    color: #333;
}

.kpi-change {
    font-size: 14px;
    color: #16a34a;
    font-weight: 500;
}

.kpi-change.negative {
    color: #dc2626;
}

.change-arrow {
    margin-right: 5px;
}

/* Tabs */
.analytics-tabs {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tabs-header {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-wrap: wrap;
}

.tab-button {
    flex: 1;
    min-width: 100px;
    padding: 15px 20px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    color: #666;
    white-space: nowrap;
}

.tab-button:hover {
    color: #333;
    background: #f0f0f0;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
}

.tab-content {
    display: none;
    padding: 30px 20px;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease-in;
}

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

/* Tables */
.table-container {
    overflow-x: auto;
}

.analytics-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.analytics-table thead th {
    background: #f3f4f6;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.analytics-table thead th.sortable {
    padding-right: 25px;
}

.analytics-table thead th.sortable:after {
    content: '↕';
    position: absolute;
    right: 8px;
    font-size: 10px;
    opacity: 0.3;
}

.analytics-table thead th.sortable.sort-asc:after {
    content: '↑';
    opacity: 1;
}

.analytics-table thead th.sortable.sort-desc:after {
    content: '↓';
    opacity: 1;
}

.analytics-table thead th.sortable:hover {
    background: #e5e7eb;
}

.analytics-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
}

.analytics-table tbody tr {
    transition: background 0.2s;
}

.analytics-table tbody tr:hover {
    background: #f9fafb;
}

.analytics-table tbody tr.profit-positive {
    background: #f0fdf4;
}

.analytics-table tbody tr.profit-negative {
    background: #fef2f2;
}

/* Orders Tab */
.orders-controls {
    margin-bottom: 20px;
}

.orders-controls input {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    max-width: 400px;
}

/* GST Tab */
.gst-container h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
}

.gst-summary {
    margin-top: 30px;
}

.gst-box {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 400px;
    font-size: 14px;
    box-shadow: 0 4px 8px rgba(22, 163, 74, 0.2);
}

.gst-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    align-items: center;
}

.gst-divider {
    height: 1px;
    background: rgba(255,255,255,0.3);
    margin: 10px 0;
}

.gst-payable {
    padding-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.3);
}

/* Monthly Analytics */
.monthly-controls {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.month-selector {
    display: flex;
    gap: 10px;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
}

.month-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s;
}

.month-btn:hover {
    background: #f5f5f5;
    border-color: #667eea;
}

.product-filter {
    display: flex;
    gap: 10px;
    align-items: center;
}

.product-filter label {
    font-weight: 600;
    font-size: 14px;
}

.product-filter select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.product-filter select:focus {
    outline: none;
    border-color: #667eea;
}

/* Monthly Summary Cards */
.monthly-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 30px;
}

.summary-card {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
}

.summary-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.summary-card h4 {
    margin: 0 0 10px 0;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-card div {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 5px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.page-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: #667eea;
}

.page-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Flatpickr overrides */
.flatpickr-calendar {
    background: white;
    border: 1px solid #ddd;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.flatpickr-day.selected {
    background: #667eea;
    border-color: #667eea;
}

.flatpickr-day.today {
    border-color: #667eea;
}

/* Responsive */
@media (max-width: 768px) {
    .analytics-header {
        padding: 30px 15px;
    }

    .analytics-header h1 {
        font-size: 24px;
    }

    .analytics-kpi-cards {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }

    .kpi-card {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }

    .kpi-icon {
        text-align: center;
    }

    .analytics-date-picker {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .date-inputs {
        flex-direction: column;
    }

    .date-group input {
        width: 100%;
    }

    .quick-buttons {
        width: 100%;
    }

    .quick-date-btn {
        flex: 1;
    }

    .tabs-header {
        flex-wrap: wrap;
    }

    .tab-button {
        flex: 0 0 calc(50% - 5px);
        padding: 12px 10px;
        font-size: 12px;
    }

    .tab-content {
        padding: 20px 15px;
    }

    .monthly-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .monthly-summary-cards {
        grid-template-columns: 1fr 1fr;
    }

    .gst-box {
        max-width: 100%;
    }

    .analytics-table {
        font-size: 12px;
    }

    .analytics-table thead th,
    .analytics-table tbody td {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .analytics-header h1 {
        font-size: 20px;
    }

    .kpi-card {
        padding: 12px;
    }

    .kpi-value {
        font-size: 18px;
    }

    .tab-button {
        flex: 0 0 50%;
        padding: 10px;
        font-size: 11px;
    }

    .monthly-summary-cards {
        grid-template-columns: 1fr;
    }

    .monthly-controls {
        width: 100%;
    }

    .product-filter {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    .product-filter select {
        width: 100%;
    }

    .orders-controls input {
        width: 100%;
    }
}
