/* Invoice.me - Custom Styles */
/* RULE: All custom styles go here, never inline or in <style> tags */

body {
    font-family: 'Inter', sans-serif;
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    display: inline-block;
    vertical-align: middle;
}

/* Navigation */
.nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(26, 43, 61, 0.7);
    transition: color 0.2s;
}

.nav-link:hover {
    color: #1a2b3d;
}

.nav-link-active {
    color: #1a2b3d;
    font-weight: 700;
    border-bottom: 2px solid #1a2b3d;
    padding-bottom: 0.25rem;
}

/* Auth page split background */
.auth-split-bg {
    background: linear-gradient(rgba(26, 43, 61, 0.85), rgba(26, 43, 61, 0.95)),
                url('https://images.unsplash.com/photo-1554224155-6726b3ff858f?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80');
    background-size: cover;
    background-position: center;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: toastSlideIn 0.3s ease-out, toastFadeOut 0.3s ease-in 2.7s forwards;
    max-width: 400px;
}

.toast-success {
    background-color: #059669;
}

.toast-error {
    background-color: #dc2626;
}

.toast-info {
    background-color: #2563eb;
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Confirm modal */
.confirm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal-overlay.hidden {
    display: none;
}

.confirm-modal-box {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* Loading spinner */
.spinner-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(26, 43, 61, 0.1);
    border-top-color: #1a2b3d;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Logo upload area */
.logo-upload-area {
    width: 128px;
    height: 128px;
    border-radius: 12px;
    border: 2px dashed rgba(26, 43, 61, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s;
    overflow: hidden;
    position: relative;
}

.logo-upload-area:hover {
    border-color: rgba(26, 43, 61, 0.4);
}

.logo-upload-area img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

/* Invoice template cards */
.template-card {
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    transform: translateY(-2px);
}

.template-card.selected {
    border-color: #1a2b3d;
    box-shadow: 0 0 0 2px #1a2b3d;
}

/* Invoice list status filter buttons (next to "Recent Invoices") */
.invoice-filter-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    border: 2px solid transparent;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    cursor: pointer;
}

.invoice-filter-btn:hover {
    filter: brightness(0.97);
}

.invoice-filter-selected {
    border-color: rgba(0, 0, 0, 0.2);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.invoice-filter-all {
    background-color: #f3f4f6;
    color: #4b5563;
}

.invoice-filter-all.invoice-filter-selected {
    background-color: #1a2b3d;
    color: white;
}

.invoice-filter-draft {
    background-color: #e5e7eb;
    color: #4b5563;
}

.invoice-filter-draft.invoice-filter-selected {
    background-color: #4b5563;
    color: white;
}

.invoice-filter-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.invoice-filter-pending.invoice-filter-selected {
    background-color: #d97706;
    color: white;
}

.invoice-filter-sent {
    background-color: #dbeafe;
    color: #1e40af;
}

.invoice-filter-sent.invoice-filter-selected {
    background-color: #2563eb;
    color: white;
}

.invoice-filter-paid {
    background-color: #d1fae5;
    color: #065f46;
}

.invoice-filter-paid.invoice-filter-selected {
    background-color: #059669;
    color: white;
}

.invoice-filter-refunded {
    background-color: #f3e8ff;
    color: #6b21a8;
}

.invoice-filter-refunded.invoice-filter-selected {
    background-color: #7c3aed;
    color: white;
}

.invoice-filter-overdue {
    background-color: #fee2e2;
    color: #991b1b;
}

.invoice-filter-overdue.invoice-filter-selected {
    background-color: #dc2626;
    color: white;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    border: none;
    outline: none;
}

.status-paid {
    background-color: #d1fae5;
    color: #065f46;
}

.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.status-overdue {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-draft {
    background-color: #f3f4f6;
    color: #4b5563;
}

.status-sent {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-refunded {
    background-color: #f3e8ff;
    color: #6b21a8;
}

/* Status dropdown */
.status-dropdown-wrapper {
    position: relative;
}

.status-dropdown {
    background: white;
    border: 1px solid rgba(26, 43, 61, 0.1);
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    min-width: 140px;
    animation: dropdownFadeIn 0.15s ease-out;
}

/* Floating dropdown: fixed position so it is never clipped by table overflow */
.status-dropdown-floating {
    position: fixed;
    z-index: 9999;
}

.status-dropdown.hidden {
    display: none;
}

.status-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 12px;
    border: none;
    background: none;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.1s;
    white-space: nowrap;
}

.status-dropdown-item:hover {
    background-color: #f1f5f9;
    color: #1a2b3d;
}

.status-dropdown-active {
    background-color: #f0f9ff;
    color: #1a2b3d;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot-draft { background-color: #9ca3af; }
.status-dot-pending { background-color: #f59e0b; }
.status-dot-sent { background-color: #3b82f6; }
.status-dot-paid { background-color: #10b981; }
.status-dot-refunded { background-color: #8b5cf6; }

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Customer logo in table */
.customer-logo-cell {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(26, 43, 61, 0.05);
}

.customer-logo-cell img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Mobile nav toggle */
.mobile-nav {
    display: none;
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
    }
}

/* Email modal */
.email-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9997;
    display: flex;
    align-items: center;
    justify-content: center;
}

.email-modal-overlay.hidden {
    display: none;
}

.email-modal-box {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* Template HTML editor */
.template-html-editor {
    min-height: 400px;
    tab-size: 2;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    background-color: #fafbfc;
}

/* Line item row animation */
.line-item-row {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Invoices list: newly added row highlight (background polling) */
.invoice-row-new {
    animation: invoiceRowGlow 2s ease-out forwards;
}

@keyframes invoiceRowGlow {
    0% {
        box-shadow: inset 0 0 0 2px rgba(26, 43, 61, 0.5);
        background-color: rgba(26, 43, 61, 0.06);
    }
    70% {
        box-shadow: inset 0 0 0 2px rgba(26, 43, 61, 0.25);
        background-color: rgba(26, 43, 61, 0.04);
    }
    100% {
        box-shadow: none;
        background-color: transparent;
    }
}

/* Invoices list: row removed elsewhere – disappearing animation */
.invoice-row-removing {
    animation: invoiceRowRemoving 0.5s ease-in forwards;
    pointer-events: none;
}

@keyframes invoiceRowRemoving {
    0% {
        opacity: 1;
        max-height: 120px;
        transform: scaleY(1);
    }
    100% {
        opacity: 0;
        max-height: 0;
        min-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        overflow: hidden;
        transform: scaleY(0.5);
        border: none;
    }
}

/* Invoices list: cell updated by background poll (number, date, amount, status) */
.invoice-cell-updated {
    animation: invoiceCellHighlight 1.5s ease-out forwards;
}

@keyframes invoiceCellHighlight {
    0% {
        background-color: rgba(26, 43, 61, 0.12);
        box-shadow: inset 0 0 0 1px rgba(26, 43, 61, 0.25);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

/* Edit invoice: field updated by background poll */
.field-updated {
    animation: fieldUpdatedHighlight 1.5s ease-out forwards;
}

@keyframes fieldUpdatedHighlight {
    0% {
        background-color: rgba(26, 43, 61, 0.12);
        box-shadow: 0 0 0 1px rgba(26, 43, 61, 0.3);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}
