/* GrantMatrix Shared Styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Space+Grotesk:wght@400;500;600;700&display=swap');

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

:root {
    --bg: #ffffff;
    --surface: #f9fafb;
    --surface-2: #f3f4f6;
    --border: #e5e7eb;
    --text: #2d3748;
    --text-muted: #6b7280;
    --accent: #1b3a5c;
    --accent-dim: rgba(27, 58, 92, 0.08);
    --accent-glow: rgba(27, 58, 92, 0.12);
    --warm: #f59e0b;
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.08);
    --success: #10b981;
    --success-dim: rgba(16, 185, 129, 0.08);
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.15;
}

/* NAV */
.app-nav {
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.app-nav .nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text);
    letter-spacing: -0.02em;
    text-decoration: none;
}
.logo span { color: var(--accent); }

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}
.nav-right a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}
.nav-right a:hover { color: var(--text); }

/* AUTH FORMS */
.auth-container {
    max-width: 420px;
    margin: 80px auto;
    padding: 0 24px;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px 36px;
}
.auth-card h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
    font-weight: 700;
}
.auth-card .subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    outline: none;
}
.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-group input::placeholder {
    color: #d1d5db;
}

.btn-submit {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 10px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.25s;
    margin-top: 8px;
}
.btn-submit:hover {
    background: #153050;
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(27, 58, 92, 0.25);
}
.btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.auth-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.auth-footer a:hover {
    text-decoration: underline;
}

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 20px;
}
.alert-error {
    background: var(--danger-dim);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}
.alert-success {
    background: var(--success-dim);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent);
}

/* DASHBOARD */
.dashboard-layout {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 24px;
}
.dashboard-header {
    margin-bottom: 40px;
}
.dashboard-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.dashboard-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 24px;
}
.card h2 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    font-weight: 600;
}
.card .card-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* Keyword input */
.keyword-input-row {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}
.keyword-input-row input {
    flex: 1;
    padding: 12px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}
.keyword-input-row input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.keyword-input-row input::placeholder {
    color: #d1d5db;
}
.btn-add {
    padding: 12px 24px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 10px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-add:hover {
    background: #153050;
}
.btn-add:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Keyword tags */
.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-dim);
    border: 1px solid rgba(27, 58, 92, 0.15);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 0.9rem;
    color: var(--accent);
    transition: all 0.2s;
}
.keyword-tag .remove-btn {
    background: none;
    border: none;
    color: rgba(27, 58, 92, 0.4);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}
.keyword-tag .remove-btn:hover {
    color: var(--danger);
}
.keywords-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
    padding: 12px 0;
}

/* Subscription status */
.sub-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
}
.sub-active {
    background: var(--success-dim);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #059669;
}
.sub-inactive {
    background: var(--danger-dim);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #dc2626;
}

/* Paywall overlay */
.paywall {
    text-align: center;
    padding: 60px 24px;
}
.paywall h2 {
    font-size: 1.5rem;
    margin-bottom: 12px;
}
.paywall p {
    color: var(--text-muted);
    margin-bottom: 32px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}
.btn-subscribe {
    display: inline-block;
    padding: 14px 40px;
    background: var(--accent);
    color: var(--bg);
    border-radius: 10px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.25s;
}
.btn-subscribe:hover {
    background: #153050;
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(27, 58, 92, 0.25);
}

/* Scan Button */
.btn-scan {
    padding: 8px 20px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-scan:hover {
    background: #153050;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(27, 58, 92, 0.2);
}
.btn-scan:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Scan Status */
.scan-status-card {
    border-color: var(--accent);
    background: var(--accent-dim);
}
.scan-progress {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.95rem;
    color: var(--accent);
    font-weight: 500;
}
.scan-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--accent-dim);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Grant Cards */
.grants-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.grant-card {
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}
.grant-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.grant-card:first-child {
    padding-top: 0;
}
.grant-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}
.grant-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--accent);
    text-decoration: none;
    line-height: 1.35;
    flex: 1;
}
.grant-title:hover {
    text-decoration: underline;
}
.grant-source {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 100px;
    background: var(--surface-2);
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.grant-agency {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.grant-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 10px;
}
.grant-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    font-size: 0.82rem;
}
.grant-deadline {
    font-weight: 600;
}
.grant-funding {
    color: var(--text);
    font-weight: 500;
}
.grant-keywords {
    color: var(--text-muted);
    font-size: 0.78rem;
    background: var(--surface-2);
    padding: 2px 10px;
    border-radius: 100px;
}

/* Grants count badge */
.grants-count {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 4px 14px;
    border-radius: 100px;
}

/* Empty state */
.grants-empty {
    text-align: center;
    padding: 40px 20px;
}
.grants-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}
.grants-empty p {
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 360px;
    margin: 0 auto;
}

/* Deadline card highlight */
.deadline-card {
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.03);
}

/* Logout link */
.btn-logout {
    color: var(--text-muted) !important;
    font-size: 0.85rem !important;
}
.btn-logout:hover {
    color: var(--danger) !important;
}

@media (max-width: 480px) {
    .keyword-input-row {
        flex-direction: column;
    }
    .auth-card {
        padding: 28px 20px;
    }
    .grant-header {
        flex-direction: column;
        gap: 6px;
    }
    .grant-meta {
        gap: 10px;
    }
    .card {
        padding: 20px 16px;
    }
}
