/* ============================================
   Portal CSS - Clean, modern design system
   ============================================ */

:root {
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-secondary: #64748b;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-bg: #ffffff;
    --color-bg-secondary: #f8fafc;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--color-bg-secondary);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Navigation
   ============================================ */
.navbar {
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.nav-links a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}
.nav-links a:hover { color: var(--color-primary); }
.lang-switcher {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
}
.lang-switcher a { color: var(--color-text-muted); }
.lang-switcher a.active { color: var(--color-primary); font-weight: 600; }

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary {
    background: var(--color-bg-secondary);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger {
    background: var(--color-danger);
    color: #fff;
}
.btn-danger:hover { background: #dc2626; }
.btn-outline {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-outline:hover { background: var(--color-bg-secondary); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   Forms
   ============================================ */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--color-text);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-error {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    color: var(--color-danger);
    margin-bottom: 1rem;
}

/* ============================================
   Layout
   ============================================ */
.main-content { min-height: calc(100vh - 120px); }
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.text-center { text-align: center; }
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fef3c7; color: #92400e; }
.badge-expired { background: #fee2e2; color: #991b1b; }

/* ============================================
   Hero Section
   ============================================ */
.hero {
    background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
    padding: 5rem 1.5rem;
    text-align: center;
}
.hero-content { max-width: 700px; margin: 0 auto; }
.hero h1 {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1.25rem;
    color: var(--color-text);
}
.hero-subtitle {
    font-size: 1.125rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}
.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   Features
   ============================================ */
.features { padding: 4rem 1.5rem; background: var(--color-bg-secondary); }
.features-grid {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}
.feature-card {
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    transition: box-shadow var(--transition);
}
.feature-card:hover { box-shadow: var(--shadow-md); }
.feature-icon { font-size: 2rem; margin-bottom: 1rem; }
.feature-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.feature-card p { color: var(--color-text-muted); font-size: 0.9rem; }

/* ============================================
   CTA Section
   ============================================ */
.cta-section {
    background: var(--color-primary);
    color: #fff;
    padding: 4rem 1.5rem;
    text-align: center;
}
.cta-section h2 { font-size: 2rem; margin-bottom: 0.75rem; }
.cta-section p { opacity: 0.9; margin-bottom: 2rem; }
.cta-section .btn-primary {
    background: #fff;
    color: var(--color-primary);
}
.cta-section .btn-primary:hover { background: #f8fafc; }

/* ============================================
   Pricing
   ============================================ */
.pricing-page { max-width: 1000px; margin: 0 auto; padding: 3rem 1.5rem; }
.page-header { text-align: center; margin-bottom: 3rem; }
.page-header h1 { font-size: 2.25rem; margin-bottom: 0.75rem; }
.page-header p { color: var(--color-text-muted); }
.pricing-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
}
.toggle {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--color-border);
    border-radius: 9999px;
    transition: background var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--color-primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }
.badge-save {
    background: var(--color-success);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    margin-left: 0.25rem;
}
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.skill-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: box-shadow var(--transition), transform var(--transition);
}
.skill-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.skill-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}
.skill-header h3 { font-size: 1.1rem; }
.skill-thumbnail { width: 48px; height: 48px; border-radius: var(--radius); object-fit: cover; }
.skill-description { color: var(--color-text-muted); font-size: 0.875rem; margin-bottom: 1rem; }
.skill-pricing { margin-bottom: 1rem; }
.price-tier {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}
.price-tier:last-child { border-bottom: none; }
.tier-label { color: var(--color-text-muted); }
.tier-price { font-weight: 600; }
.skill-actions { display: flex; gap: 0.5rem; }

/* ============================================
   Auth Pages
   ============================================ */
.auth-page {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    background: var(--color-bg-secondary);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}
.auth-header { text-align: center; margin-bottom: 1.5rem; }
.auth-header h1 { font-size: 1.5rem; margin-bottom: 0.375rem; }
.auth-header p { color: var(--color-text-muted); font-size: 0.9rem; }
.auth-form .btn { margin-top: 0.5rem; }
.auth-footer { text-align: center; margin-top: 1rem; }
.auth-footer a { color: var(--color-primary); font-size: 0.875rem; }
.auth-divider {
    text-align: center;
    margin: 1.5rem 0;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}
.terms-text { font-size: 0.8rem; color: var(--color-text-muted); text-align: center; margin-top: 0.75rem; }
.terms-text a { color: var(--color-primary); }

/* ============================================
   Verify Page
   ============================================ */
.verify-page {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.verify-card { text-align: center; }
.verify-icon {
    font-size: 3rem;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.verify-success .verify-icon { background: #dcfce7; color: var(--color-success); }
.verify-error .verify-icon { background: #fee2e2; color: var(--color-danger); }
.verify-card h1 { font-size: 1.5rem; margin-bottom: 0.75rem; }
.verify-card p { color: var(--color-text-muted); margin-bottom: 1.5rem; }

/* ============================================
   Dashboard
   ============================================ */
.dashboard-layout { background: var(--color-bg-secondary); }
.dashboard {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: calc(100vh - 60px);
}
.dashboard-sidebar {
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border);
    padding: 1.5rem 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-info strong { display: block; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { font-size: 0.75rem; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.125rem; padding: 0 0.75rem; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
}
.sidebar-link:hover { background: var(--color-bg-secondary); color: var(--color-primary); }
.sidebar-link.active { background: #eef2ff; color: var(--color-primary); }
.dashboard-main { padding: 2rem; overflow: auto; }
.dashboard-content h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon { font-size: 1.5rem; }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; color: var(--color-text-muted); }
.dashboard-section { margin-top: 2rem; }
.dashboard-section h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.quick-link-card {
    display: block;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--color-text);
    transition: all var(--transition);
}
.quick-link-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.ql-icon { font-size: 1.5rem; display: block; margin-bottom: 0.5rem; }
.ql-title { font-weight: 600; display: block; margin-bottom: 0.25rem; }
.ql-desc { font-size: 0.8rem; color: var(--color-text-muted); }
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.section-header h1 { margin-bottom: 0; }
.new-key-alert {
    border-color: var(--color-warning);
    background: #fffbeb;
}
.new-key-alert h3 { color: #92400e; margin-bottom: 0.5rem; }
.new-key-display {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-family: monospace;
    word-break: break-all;
    margin: 0.75rem 0;
}
.api-key-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}
.api-key-row.new-key { border-color: var(--color-warning); background: #fffbeb; }
.key-name { font-weight: 600; }
.key-prefix { font-family: monospace; font-size: 0.875rem; color: var(--color-text-muted); }
.key-meta { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.key-plaintext { margin-top: 0.75rem; }
.key-code { font-family: monospace; font-size: 0.875rem; word-break: break-all; }

/* ============================================
   Subscriptions
   ============================================ */
.subscriptions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}
.subscription-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.sub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.sub-details { margin-bottom: 1rem; }
.sub-detail {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}
.sub-detail:last-child { border-bottom: none; }
.detail-label { color: var(--color-text-muted); }
.detail-value { font-weight: 500; }
.sub-actions { display: flex; gap: 0.5rem; }

/* ============================================
   Tables
   ============================================ */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--color-border);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}
.table tbody tr:hover { background: var(--color-bg-secondary); }

/* ============================================
   Usage Chart
   ============================================ */
.usage-chart { padding: 1rem 0; }
.chart-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.chart-label {
    min-width: 120px;
    font-size: 0.875rem;
    font-weight: 500;
}
.chart-bar-container {
    flex: 1;
    height: 24px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
}
.chart-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    transition: width 0.5s ease;
    min-width: fit-content;
}
.chart-value { font-size: 0.75rem; color: #fff; font-weight: 600; }
.chart-remaining {
    min-width: 80px;
    text-align: right;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}
.empty-state p { margin-bottom: 1rem; }

/* ============================================
   Footer
   ============================================ */
.footer {
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border);
    padding: 2rem 0;
    margin-top: 3rem;
}
.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.footer-links { display: flex; gap: 1.5rem; }
.footer-links a { color: var(--color-text-muted); text-decoration: none; font-size: 0.875rem; }
.footer-links a:hover { color: var(--color-text); }
.footer p { font-size: 0.875rem; color: var(--color-text-muted); }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    .dashboard-sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    .hero h1 { font-size: 2rem; }
    .form-row { grid-template-columns: 1fr; }
    .footer-container { flex-direction: column; gap: 1rem; text-align: center; }
}

/* ============================================
   HTMX Transitions
   ============================================ */
.htmx-indicator { opacity: 0.5; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }
