/**
 * Owner Dashboard Styles
 *
 * Clean, modern, responsive design for the Vue 3 SPA.
 */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a2e;
    background: #f0f2f5;
}

/* ── Loading Screen ───────────────────────────────────────── */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── Login ────────────────────────────────────────────────── */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a2e;
}

.login-header p {
    color: #666;
    margin-top: 4px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
}

.login-form input[type="email"],
.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-form input:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

.login-form .form-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 8px 0;
}

.login-form .form-help {
    color: #666;
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.login-form .form-footer {
    text-align: center;
    margin-top: 16px;
    margin-bottom: 4px;
}

.login-form .forgot-link {
    color: #2563eb;
    font-size: 13px;
    text-decoration: none;
}

.login-form .forgot-link:hover {
    text-decoration: underline;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn-outline {
    background: #fff;
    color: #374151;
    border-color: #d1d5db;
}

.btn-outline:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-success {
    background: #059669;
    color: #fff;
    border-color: #059669;
}

.btn-success:hover:not(:disabled) {
    background: #047857;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* ── Dashboard Header ─────────────────────────────────────── */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
}

.view-tabs {
    display: flex;
    gap: 4px;
}

.tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.tab:hover {
    background: #f3f4f6;
    color: #374151;
}

.tab.active {
    background: #eff6ff;
    color: #2563eb;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.owner-name {
    font-weight: 500;
    color: #374151;
}

/* ── Dashboard Main ───────────────────────────────────────── */
.dashboard-main {
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ── Report Filters ───────────────────────────────────────── */
.report-filters {
    background: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-group {
    display: flex;
    gap: 4px;
}

.dates .date-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    width: 130px;
}

.date-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.date-separator {
    color: #9ca3af;
    font-size: 13px;
}

.toggles {
    flex-direction: row;
    gap: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
}

/* ── Loading Bar ──────────────────────────────────────────── */
.loading-bar {
    height: 3px;
    background: #e5e7eb;
    border-radius: 2px;
    margin-bottom: 16px;
    overflow: hidden;
}

.loading-bar-inner {
    height: 100%;
    background: #2563eb;
    border-radius: 2px;
    animation: loading-slide 1s ease-in-out infinite;
    width: 30%;
}

@keyframes loading-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

/* ── Summary Cards ────────────────────────────────────────── */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.card {
    background: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.card-value {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
}

.card-value.currency {
    color: #059669;
}

.card-period {
    font-size: 14px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

/* ── Report Table ─────────────────────────────────────────── */
.report-table-wrapper {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow-x: auto;
    overflow-y: auto;
    max-height: var(--table-max-height, none);
}

.report-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    min-width: 900px;
}

.report-table th,
.report-table td {
    padding: 8px 10px;
    text-align: right;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
}

.report-table th {
    background: #dce3eb;
    font-weight: 600;
    color: #1e293b;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 2;
}

.report-table th:hover {
    background: #cdd5e0;
}

.report-table thead tr:first-child th {
    font-weight: 700;
}

.report-table thead tr:first-child th.col-trans {
    text-align: center;
}

.sub-header th {
    background: #e8edf3;
    font-size: 11px;
    font-weight: 500;
    color: #475569;
    padding: 4px 10px;
    text-transform: none;
    cursor: default;
    z-index: 1;
}

.report-table td {
    color: #374151;
}

.report-table .alt-row {
    background: #fafbfc;
}

.report-table .num {
    font-variant-numeric: tabular-nums;
}

.report-table .col-store {
    text-align: left;
    font-weight: 500;
}

.report-table .col-trans.col-shaded {
    background-color: #e2e8f0;
}

.report-table .col-premium {
    background-color: #fef3c7;
}

.report-table .col-region {
    text-align: center;
}

.subtotal-row td,
.region-row td,
.grand-total-row td,
.averages-row td {
    font-weight: 600;
    background: #f0fdf4;
    border-top: 2px solid #bbf7d0;
}

.region-row td {
    background: #eff6ff;
    border-top-color: #bfdbfe;
}

.grand-total-row td {
    background: #fefce8;
    border-top-color: #fde047;
}

.averages-row td {
    background: #fdf4ff;
    border-top-color: #e9d5ff;
}

.section-divider-row td {
    padding: 0;
    border-bottom: none;
}

.section-divider {
    border: none;
    border-top: 1px solid #d1d5db;
    margin: 4px 0;
}

.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
    font-size: 16px;
}

/* ── Competition Section ──────────────────────────────────── */
.competition-section {
    margin-top: 32px;
}

.competition-section .section-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        height: auto;
        padding: 12px 16px;
        gap: 12px;
    }

    .header-left {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .view-tabs {
        width: 100%;
    }

    .tab {
        flex: 1;
        text-align: center;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

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

    .dashboard-main {
        padding: 16px;
    }
}

/* ── Expanded Report ────────────────────────────────────── */
.client-section {
    margin-bottom: 2rem;
}

.expanded-table .sub-col {
    font-size: 0.75em;
    color: #666;
    display: block;
}

.ins-company-section {
    background: #f8f9fa;
}

.ins-company-row td {
    font-size: 0.9em;
}

/* ── Sales Comparison ───────────────────────────────────── */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
    padding: 6px 10px;
    border: 1px solid #ddd;
    text-align: right;
}

.chart-container {
    width: 100%;
    height: 300px;
    margin: 1rem 0;
}

/* ── Competition Panel ──────────────────────────────────── */
.competition-panel {
    max-width: 800px;
}

.comp-section {
    margin-bottom: 2rem;
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.comp-section h3 {
    margin-top: 0;
    border-bottom: 2px solid #0366d6;
    padding-bottom: 0.5rem;
}

.comp-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.store-picker {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 0.5rem;
    border-radius: 4px;
}

.store-picker label {
    display: block;
    padding: 0.25rem 0;
}

.store-picker input {
    margin-right: 0.5rem;
}

.form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.owner-info {
    margin: 0.5rem 0;
    color: #28a745;
    font-weight: 600;
}

.input {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* ── Settings View ──────────────────────────────────────── */
.settings-view {
    max-width: 600px;
}

.setting-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.setting-section h2 {
    margin-top: 0;
    border-bottom: 2px solid #0366d6;
    padding-bottom: 0.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.form-group.checkbox label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
}

/* ── Password Input Wrapper ─────────────────────────────── */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    padding-right: 2.5rem;
}

.toggle-password {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: #6b7280;
    line-height: 1;
    display: flex;
    align-items: center;
}

.toggle-password:hover {
    color: #374151;
}

.password-criteria {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* ── Modals (shared) ────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-dialog {
    background: #fff;
    border-radius: 8px;
    padding: 2rem;
    min-width: 400px;
    max-width: 500px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ── Export Button ──────────────────────────────────────── */
.export-btn {
    float: right;
    margin-bottom: 1rem;
}

/* ── Alert Success ──────────────────────────────────────── */
.alert-success {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

/* ── Alert Info ─────────────────────────────────────────── */
.alert-info {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

/* ── Version Banner ─────────────────────────────────────── */
.version-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1.5rem;
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    font-size: 0.875rem;
}
.version-banner-text {
    flex: 1;
    color: #92400e;
}
.version-banner-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: #92400e;
    padding: 0.25rem;
}
.version-banner-close:hover {
    color: #78350f;
}
