/* Nube Azul Invoice — SaaS theme */

:root {
    --saas-bg: #F6F8FB;
    --saas-sidebar: #0F172A;
    --saas-sidebar-hover: #1E293B;
    --saas-primary: #2563EB;
    --saas-primary-hover: #1D4ED8;
    --saas-card-bg: #FFFFFF;
    --saas-border: #E2E8F0;
    --saas-text: #0F172A;
    --saas-muted: #64748B;
    --saas-radius: 12px;
    --saas-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
}

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--saas-bg);
    color: var(--saas-text);
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--saas-primary);
}

.btn-primary {
    background-color: var(--saas-primary);
    border-color: var(--saas-primary);
}

.btn-primary:hover {
    background-color: var(--saas-primary-hover);
    border-color: var(--saas-primary-hover);
}

/* App shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--saas-sidebar);
    color: #E2E8F0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    background: var(--saas-card-bg);
    border-bottom: 1px solid var(--saas-border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-topbar__search {
    flex: 1;
    max-width: 420px;
}

.app-search {
    border-radius: 8px;
    border-color: var(--saas-border);
    background: var(--saas-bg);
    font-size: 0.9rem;
}

.app-topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-topbar__user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-topbar__email {
    font-size: 0.85rem;
    color: var(--saas-muted);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-content {
    padding: 1.5rem;
    flex: 1;
}

/* Sidebar */
.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #F8FAFC;
}

.sidebar-brand__mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563EB, #3B82F6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
}

.sidebar-brand__text {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
}

.sidebar-nav {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748B;
    padding: 1rem 0.75rem 0.35rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: #CBD5E1;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
    background: var(--saas-sidebar-hover);
    color: #F8FAFC;
}

.sidebar-link.active {
    background: rgba(37, 99, 235, 0.2);
    color: #93C5FD;
}

.sidebar-link__icon {
    width: 1.25rem;
    text-align: center;
    opacity: 0.85;
}

/* Cards */
.saas-card {
    background: var(--saas-card-bg);
    border: 1px solid var(--saas-border);
    border-radius: var(--saas-radius);
    box-shadow: var(--saas-shadow);
}

.stat-card {
    padding: 1.25rem;
}

.stat-card__label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--saas-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.stat-card__value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--saas-text);
    line-height: 1.2;
}

.stat-card__subtitle {
    font-size: 0.8rem;
    color: var(--saas-muted);
    margin-top: 0.35rem;
}

.quick-action-card {
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    color: inherit;
}

.quick-action-card:hover {
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.1);
    transform: translateY(-1px);
}

/* Page header */
.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.page-header__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.page-header__subtitle {
    color: var(--saas-muted);
    margin: 0.25rem 0 0;
    font-size: 0.95rem;
}

.page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge--draft { background: #F1F5F9; color: #475569; }
.status-badge--sent { background: #DBEAFE; color: #1D4ED8; }
.status-badge--paid { background: #DCFCE7; color: #15803D; }
.status-badge--overdue { background: #FEE2E2; color: #B91C1C; }
.status-badge--void { background: #F1F5F9; color: #94A3B8; }

/* Section card */
.section-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--saas-border);
    gap: 1rem;
}

.section-card__header--clickable {
    cursor: pointer;
    user-select: none;
}

.section-card__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.section-card__subtitle {
    font-size: 0.8rem;
    color: var(--saas-muted);
    margin: 0.15rem 0 0;
}

.section-card__chevron {
    font-size: 1.25rem;
    color: var(--saas-muted);
    transition: transform 0.2s;
    transform: rotate(90deg);
}

.section-card__chevron.expanded {
    transform: rotate(-90deg);
}

.section-card__body {
    padding: 1.25rem;
}

/* Empty state */
.empty-state {
    padding: 3rem 2rem;
    text-align: center;
}

.empty-state__icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.empty-state__title {
    font-size: 1.15rem;
    font-weight: 600;
}

.empty-state__text {
    color: var(--saas-muted);
    max-width: 400px;
    margin: 0.5rem auto 0;
}

.empty-state__actions {
    margin-top: 1.25rem;
}

/* Data table */
.saas-table {
    width: 100%;
    margin: 0;
}

.saas-table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--saas-muted);
    border-bottom: 1px solid var(--saas-border);
    padding: 0.75rem 1rem;
    background: #FAFBFC;
}

.saas-table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--saas-border);
    vertical-align: middle;
    font-size: 0.9rem;
}

.saas-table tbody tr:hover {
    background: #F8FAFC;
}

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

/* Revenue chart */
.revenue-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    height: 160px;
    padding-top: 1rem;
}

.revenue-chart__bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    height: 100%;
    justify-content: flex-end;
}

.revenue-chart__bar {
    width: 100%;
    max-width: 48px;
    background: linear-gradient(180deg, #3B82F6, #2563EB);
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    transition: height 0.3s;
}

.revenue-chart__label {
    font-size: 0.7rem;
    color: var(--saas-muted);
    text-align: center;
}

.revenue-chart--annual {
    height: 240px;
    gap: 0.5rem;
}

.revenue-chart--annual .revenue-chart__bar {
    max-width: 36px;
}

.revenue-chart__amount {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--saas-text);
    text-align: center;
    line-height: 1.2;
    min-height: 2rem;
}

/* Invoice list table — keep action dropdowns visible */
.saas-card--table {
    overflow: visible;
}

.invoice-table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 0.25rem;
}

.saas-table .invoice-actions-cell {
    min-width: 7rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    vertical-align: middle;
}

.saas-table .dropdown-menu {
    z-index: 1050;
}

/* Status breakdown */
.status-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.status-breakdown__row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-breakdown__bar {
    flex: 1;
    height: 8px;
    background: #F1F5F9;
    border-radius: 4px;
    overflow: hidden;
}

.status-breakdown__fill {
    height: 100%;
    border-radius: 4px;
}

.status-breakdown__count {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 2rem;
    text-align: right;
}

/* Invoice editor layout */
.invoice-editor-grid {
    display: grid;
    grid-template-columns: 280px 1fr 380px;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 1199px) {
    .invoice-editor-grid {
        grid-template-columns: 1fr;
    }
}

.invoice-editor-panel {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.invoice-preview-sticky {
    position: sticky;
    top: 80px;
}

.invoice-action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--saas-card-bg);
    border: 1px solid var(--saas-border);
    border-radius: var(--saas-radius);
    margin-bottom: 1rem;
}

/* Client cards */
.client-card {
    padding: 1rem 1.25rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    cursor: pointer;
}

.client-card:hover {
    border-color: #93C5FD;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.client-card__name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.client-card__meta {
    font-size: 0.85rem;
    color: var(--saas-muted);
}

/* Modal */
.saas-modal-backdrop {
    background-color: rgba(15, 23, 42, 0.45);
}

/* Premium invoice preview */
.invoice-doc {
    background: #fff;
    border-radius: var(--saas-radius);
    overflow: hidden;
    border: 1px solid var(--saas-border);
    box-shadow: var(--saas-shadow);
}

.invoice-doc__accent {
    height: 6px;
    background: linear-gradient(90deg, #2563EB, #3B82F6);
}

.invoice-doc__body {
    padding: 2rem;
}

.invoice-doc__title {
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    color: var(--saas-text);
}

.invoice-doc__totals-card {
    background: #F8FAFC;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-left: auto;
    max-width: 280px;
}

.invoice-doc__totals-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    font-size: 0.9rem;
}

.invoice-doc__totals-row--total {
    font-weight: 700;
    font-size: 1.05rem;
    border-top: 2px solid var(--saas-border);
    margin-top: 0.35rem;
    padding-top: 0.65rem;
}

.invoice-doc__totals-row--balance {
    color: var(--saas-primary);
    font-weight: 700;
}

.invoice-doc table thead th {
    background: #F8FAFC;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--saas-muted);
    border-bottom: 2px solid var(--saas-border);
}

/* Responsive sidebar */
@media (max-width: 991px) {
    .app-shell {
        flex-direction: column;
    }

    .app-sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .app-topbar__email {
        display: none;
    }
}

.clickable-row { cursor: pointer; }

.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.page { display: contents; }
.content { padding: 0; }

.company-logo-preview {
    max-height: 64px;
    max-width: 160px;
    object-fit: contain;
    border: 1px solid var(--saas-border);
    border-radius: 8px;
    padding: 0.25rem;
    background: #fff;
}

.company-logo-placeholder {
    min-width: 120px;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--saas-border);
    border-radius: 8px;
    padding: 0.5rem;
    background: #F8FAFC;
}

/* Toasts */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: min(360px, calc(100vw - 2rem));
    pointer-events: none;
}

.app-toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateX(110%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

.app-toast.show { opacity: 1; transform: translateX(0); }
.app-toast-success { background: #15803D; }
.app-toast-error { background: #DC2626; }
.app-toast-info { background: var(--saas-primary); }

.app-toast-icon {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

.app-toast-message {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.4;
}

.app-toast-close {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.25rem;
    line-height: 1;
    opacity: 0.85;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.app-toast-close:hover {
    opacity: 1;
}

/* Public invoice generator */
.public-generator-layout {
    min-height: 100vh;
    background: var(--saas-bg);
}

.public-generator-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    background: var(--saas-card-bg);
    border-bottom: 1px solid var(--saas-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.public-generator-header__brand {
    font-weight: 600;
    color: var(--saas-text);
    text-decoration: none;
}

.public-generator-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

.public-generator-hero {
    max-width: 720px;
}

.public-generator-grid {
    align-items: start;
}

.public-preview-sticky {
    position: sticky;
    top: 80px;
}

.public-invoice-preview {
    box-shadow: var(--saas-shadow);
}

.template-card {
    border: 1px solid var(--saas-border, #e2e8f0);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.template-card--active {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 1px var(--bs-primary);
}

.public-seo-content {
    max-width: 900px;
}

/* Blazor error UI — hidden until a real circuit error occurs */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

@media (max-width: 991px) {
    .public-preview-sticky {
        position: static;
    }
}

/* Print */
@media print {
    .no-print,
    .app-sidebar,
    .app-topbar,
    .invoice-action-bar,
    .invoice-editor-panel:not(.print-area),
    #blazor-error-ui {
        display: none !important;
    }

    .app-shell,
    .app-main,
    .app-content {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .invoice-preview-sticky {
        position: static !important;
    }

    .invoice-doc {
        box-shadow: none !important;
        border: none !important;
    }
}
