/* Cloudi-Fi Invoice Dashboard - Redesigned */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #F6F8FD;
    --fg: #2546A6;
    --fg-dark: #1a3380;
    --fg-light: #4a6bc9;
    --border: #e0e5f2;
    --primary: #FFD400;
    --primary-hover: #ffdf33;
    --accent: #2546A6;
    --score-high: #22c55e;
    --score-medium: #FFD400;
    --score-low: #ef4444;
    --card-shadow: 0 1px 3px rgba(37, 70, 166, 0.08);
    --card-shadow-hover: 0 4px 12px rgba(37, 70, 166, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 3rem;
    background: linear-gradient(135deg, #2546A6 0%, #1a3380 100%);
    border-bottom: 3px solid var(--primary);
    box-shadow: 0 2px 8px rgba(37, 70, 166, 0.15);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 3rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    height: 32px;
    width: auto;
    filter: brightness(0) invert(1);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
    position: relative;
    padding-left: 1rem;
}

header h1::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary);
    border-radius: 2px;
}

.user-email {
    opacity: 0.9;
    font-weight: 500;
}

/* Main navigation tabs */
.main-nav {
    display: flex;
    gap: 0.25rem;
}
.nav-tab {
    padding: 0.625rem 1.25rem;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.75);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    position: relative;
}
.nav-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.nav-tab.active {
    background: var(--primary);
    color: var(--accent);
    box-shadow: 0 2px 8px rgba(255, 212, 0, 0.3);
}

main {
    padding: 2.5rem 3rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Filters */
.filters {
    background: white;
    padding: 1.5rem 1.75rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filters form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.score-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--fg);
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    transition: background 0.2s ease;
}
.score-toggle:hover {
    background: var(--bg);
}
.score-toggle input { cursor: pointer; }

.filters input[type="text"],
.filters input[type="date"],
.filters select {
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: white;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--fg);
    transition: all 0.2s ease;
}

.filters input[type="text"]:focus,
.filters input[type="date"]:focus,
.filters select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 70, 166, 0.1);
}

.filters button {
    padding: 0.625rem 1.5rem;
    background: var(--primary);
    color: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.filters button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 212, 0, 0.3);
}

.filters a {
    color: var(--fg);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.filters a:hover {
    background: var(--bg);
}

/* Table */
.invoice-table {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    overflow: visible;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: linear-gradient(to bottom, #f8f9fd, #f3f5fa);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg);
}

tr:last-child td { border-bottom: none; }

tr.needs-review {
    background: linear-gradient(to right, #fffbeb, #fef3c7);
    border-left: 4px solid var(--primary);
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: var(--bg);
}

.nowrap { white-space: nowrap; }

/* Needs review section */
.needs-review-section {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    box-shadow: var(--card-shadow);
    overflow: visible;
}

.needs-review-section h2,
.invoice-table h2 {
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-bottom: 2px solid var(--border);
    background: linear-gradient(to bottom, #f8f9fd, #f3f5fa);
    color: var(--fg);
    letter-spacing: -0.01em;
}

td a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}
td a:hover {
    color: var(--fg-dark);
    text-decoration: underline;
}

.summary {
    max-width: 400px;
}

.customer-cell { min-width: 150px; }

.score {
    font-weight: 600;
    text-align: center;
}

.score-high { color: var(--score-high); }
.score-medium { color: var(--score-medium); }
.score-low { color: var(--score-low); }

/* Score column hidden by default, shown via toggle */
.score-col { display: none; }
body.show-score-col .score-col { display: table-cell; }

.amount { text-align: right; font-variant-numeric: tabular-nums; }

.no-results {
    text-align: center;
    color: #666;
    padding: 2rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    font-size: 0.9rem;
    color: var(--fg);
}

.pagination nav { display: flex; gap: 1.5rem; }
.pagination a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}
.pagination a:hover {
    background: var(--bg);
    color: var(--fg-dark);
}

/* Customer picker */
.customer-picker { position: relative; }

.customer-display {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    border: 1px dashed transparent;
}
.customer-display:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.edit-icon {
    opacity: 0.4;
    font-size: 0.75rem;
    margin-left: 0.25rem;
}
.customer-display:hover .edit-icon { opacity: 0.8; }

.customer-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: 280px;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.customer-search-input {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}
.customer-search-input:focus { outline: none; }

.customer-options {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.customer-option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
}
.customer-option:hover { background: #f3f4f6; }

.customer-option.create-option {
    border-top: 1px solid var(--border);
    color: #D97706;
    font-weight: 500;
}
.customer-option.create-option:hover { background: #eff6ff; }

.customer-create {
    flex: 0 0 auto;
}

.no-customers, .customer-error {
    padding: 1rem;
    text-align: center;
    color: #666;
    font-size: 0.875rem;
}

/* User info */
.user-info {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    color: white;
    font-size: 0.9rem;
}
.logout-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}
.logout-link:hover {
    background: rgba(255, 212, 0, 0.15);
}

/* Row success flash */
.row-success {
    animation: flash-green 1.5s ease-out;
}
@keyframes flash-green {
    0% { background: #bbf7d0; }
    100% { background: transparent; }
}

/* Inline error */
.inline-error {
    color: var(--score-low);
    font-size: 0.875rem;
}

/* Login prompt */
.login-prompt {
    text-align: center;
    padding: 6rem 2rem;
    max-width: 500px;
    margin: 0 auto;
}
.login-prompt p {
    margin-bottom: 2rem;
    color: var(--fg);
    font-size: 1.1rem;
    line-height: 1.7;
}
.login-button {
    display: inline-block;
    padding: 1rem 2.5rem;
    background: var(--primary);
    color: var(--accent);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(255, 212, 0, 0.4);
    transition: all 0.3s ease;
}
.login-button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 212, 0, 0.5);
}

/* Follow-ups page */
.followups-section {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}
.followups-section h2 {
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-bottom: 2px solid var(--border);
    background: linear-gradient(to bottom, #f8f9fd, #f3f5fa);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--fg);
}

/* Status filter buttons */
.status-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.status-filter {
    padding: 0.625rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: white;
    color: var(--fg);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.status-filter:hover {
    background: var(--bg);
    border-color: var(--accent);
}
.status-filter.active {
    background: var(--primary);
    color: var(--accent);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(255, 212, 0, 0.3);
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.status-pending { background: #fef3c7; color: #92400e; }
.status-sent { background: #dbeafe; color: #1e40af; }
.status-failed { background: #fee2e2; color: #991b1b; }
.status-complete { background: #dcfce7; color: #166534; }
.status-stopped { background: #f3f4f6; color: #4b5563; }
/* Invoice status badges */
.status-draft { background: #f3f4f6; color: #4b5563; }
.status-viewed { background: #e0e7ff; color: #3730a3; }
.status-partial { background: #fef3c7; color: #92400e; }
.status-paid { background: #dcfce7; color: #166534; }
.status-unknown { background: #f3f4f6; color: #9ca3af; }

/* Action buttons */
.actions { display: flex; gap: 0.625rem; white-space: nowrap; }
.btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: all 0.2s ease;
    font-family: inherit;
}
.btn-primary {
    background: var(--primary);
    color: var(--accent);
    box-shadow: 0 2px 6px rgba(255, 212, 0, 0.3);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(255, 212, 0, 0.4);
}
.btn-secondary {
    background: white;
    color: var(--fg);
    border: 2px solid var(--border);
}
.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--accent);
}
.btn-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 2px solid #fecaca;
}
.btn-danger:hover {
    background: #fecaca;
    border-color: #f87171;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Refresh button in header */
.refresh-btn {
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: var(--accent);
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(255, 212, 0, 0.3);
}
.refresh-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(255, 212, 0, 0.4);
}
.refresh-btn:disabled {
    opacity: 0.5;
    cursor: wait;
    transform: none;
}

/* Row flash animations */
.row-error { animation: flash-red 1.5s ease-out; }
@keyframes flash-red {
    0% { background: #fecaca; }
    100% { background: transparent; }
}

/* Page load animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

main > * {
    animation: fadeInUp 0.4s ease-out;
}

main > *:nth-child(1) {
    animation-delay: 0.05s;
}

main > *:nth-child(2) {
    animation-delay: 0.1s;
}

main > *:nth-child(3) {
    animation-delay: 0.15s;
}

header {
    animation: slideInLeft 0.5s ease-out;
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Focus states */
*:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--primary);
    color: var(--accent);
}
