/* Analytics Dashboard Styles */

.analytics-container {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Header Section */
.analytics-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.header-top h1 {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #1a1a1a;
}

.subtitle {
    color: #666;
    font-size: 16px;
    margin: 0;
}

.header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

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

.header-controls-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.header-controls > .primary-button {
    margin-left: auto;
}

.primary-button,
.secondary-button,
.icon-button {
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.primary-button {
    background-color: #4CAF50;
    color: #ffffff;
    padding: 10px 18px;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.25);
}

.primary-button:hover:enabled {
    background-color: #43a047;
    transform: translateY(-1px);
}

.primary-button:disabled {
    background-color: #c8e6c9;
    color: #ffffff;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.secondary-button {
    background-color: #f5f5f5;
    color: #333333;
    padding: 10px 18px;
}

.secondary-button:hover:enabled {
    background-color: #e0e0e0;
    transform: translateY(-1px);
}

.secondary-button:disabled {
    background-color: #eeeeee;
    color: #9e9e9e;
    cursor: not-allowed;
    transform: none;
}

.icon-button {
    background-color: transparent;
    color: #555555;
    padding: 6px;
    border-radius: 50%;
}

.icon-button:hover:enabled {
    background-color: #f0f0f0;
}

.icon-button:disabled {
    cursor: not-allowed;
    color: #bdbdbd;
}

.date-range-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.date-input {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.date-input:hover {
    border-color: #4CAF50;
}

.date-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.site-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.site-dropdown {
    padding: 8px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.site-dropdown:hover {
    border-color: #4CAF50;
}

.site-dropdown:focus {
    outline: none;
    border-color: #4CAF50;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.metric-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s, box-shadow 0.3s;
}

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

.metric-icon {
    font-size: 48px;
    line-height: 1;
}

.metric-content {
    flex: 1;
}

.metric-label {
    font-size: 14px;
    color: #666;
    margin: 0 0 8px 0;
    font-weight: 500;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #1a1a1a;
}

.metric-change {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.metric-change.positive {
    color: #4CAF50;
    background: #e8f5e9;
}

.metric-change.negative {
    color: #f44336;
    background: #ffebee;
}

.metric-change.neutral {
    color: #757575;
    background: #f5f5f5;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chart-header {
    margin-bottom: 24px;
}

.chart-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #1a1a1a;
}

.chart-header p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.chart-content {
    min-height: 300px;
    padding: 10px;
}

/* Table Card */
.table-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.table-card + .table-card {
    margin-top: 32px;
}

.table-header {
    margin-bottom: 24px;
}

.table-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #1a1a1a;
}

.table-header p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.table-container {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
    position: relative;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    background: #f8f9fa;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    color: #555;
}

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

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    display: inline-block;
    text-transform: capitalize;
}

.status-badge.status-looking {
    background: #fff3cd;
    color: #856404;
}

.status-badge.status-filled {
    background: #d1ecf1;
    color: #0c5460;
}

.status-badge.status-not-filled {
    background: #f8d7da;
    color: #721c24;
}

.status-badge.status-canceled {
    background: #e2e3e5;
    color: #383d41;
}

.status-badge.status-approved {
    background: #d1ecf1;
    color: #0c5460;
}

/* Loading State */
.analytics-container .loading-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.analytics-container .spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

.analytics-container .loading-message p {
    color: #666;
    font-size: 16px;
    margin: 0;
}

/* Empty State */
.analytics-container .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.analytics-container .empty-state p {
    margin: 0;
    font-size: 14px;
}

/* Email Modal — scoped under .analytics-email-modal */
.analytics-email-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 2000;
    overflow-y: auto;
}

.analytics-email-modal .modal {
    position: relative;
    background: #ffffff;
    max-width: 640px;
    width: min(640px, 90vw);
    height: auto;
    min-height: 0;
    border-radius: 12px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.2);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2001;
    animation: modal-fade 0.2s ease;
}

.analytics-email-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.analytics-email-modal .modal-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
}

.analytics-email-modal .modal-description {
    margin: 0 0 8px 0;
    color: #666666;
    font-size: 14px;
}

.analytics-email-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analytics-email-modal .modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.analytics-email-modal .modal-field label {
    font-weight: 600;
    color: #333333;
    font-size: 14px;
}

.analytics-email-modal .modal-input {
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: #ffffff;
    transition: border-color 0.3s ease;
}

.analytics-email-modal .modal-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.analytics-email-modal .modal-help {
    margin: 0;
    font-size: 13px;
    color: #9e9e9e;
}

.analytics-email-modal .modal-feedback {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.analytics-email-modal .modal-feedback.success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.analytics-email-modal .modal-feedback.error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.analytics-email-modal .modal-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

@media (min-width: 768px) {
    .modal {
        padding: 26px;
        gap: 10px;
        height: auto;
    }

    .modal-body {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        align-items: start;
        align-content: start;
    }

    .modal-body .modal-field:first-of-type,
    .modal-body .modal-feedback {
        grid-column: 1 / -1;
    }

    .modal-actions {
        justify-content: flex-end;
    }
}

@keyframes modal-fade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .analytics-container {
        padding: 16px;
    }

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

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

    .header-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .header-controls-left {
        width: 100%;
        justify-content: space-between;
        gap: 12px;
    }

    .date-range-selector {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .date-input {
        flex: 1;
        min-width: 120px;
    }

    .site-selector {
        width: 100%;
        justify-content: space-between;
    }

    .site-dropdown {
        flex: 1;
    }

    .header-controls > .primary-button {
        margin-left: 0;
        width: 100%;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .metric-card {
        flex-direction: column;
        text-align: center;
    }

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

    .data-table th,
    .data-table td {
        padding: 8px 12px;
    }

    .modal {
        padding: 20px;
    }
}

/* Recipients list in email modal */
.recipients-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 4px;
    margin-bottom: 8px;
    background: #fafafa;
}

.recipient-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 4px;
    background: #fff;
    margin-bottom: 4px;
    border: 1px solid #e8e8e8;
}

.recipient-item:last-child {
    margin-bottom: 0;
}

.recipient-email {
    font-size: 13px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
}

.recipient-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
}

.recipient-remove:hover {
    background: #fee;
    color: #d32f2f;
}

.recipient-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.recipient-input {
    flex: 1;
}

.recipient-add-button {
    flex-shrink: 0;
    padding: 8px 16px;
    font-size: 13px;
}
