/* ================================================
   SIP Generator — Web Application Styles
   Clean, professional, modern design
   ================================================ */

:root {
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --accent: #764ba2;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text: #2d3748;
    --text-light: #718096;
    --text-muted: #a0aec0;
    --bg: #f7fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --success: #48bb78;
    --error: #fc8181;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

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

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

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* ---- Hero / Header ---- */

.hero {
    text-align: center;
    margin-bottom: 40px;
}

.hero-compact {
    margin-bottom: 30px;
}

.logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: var(--gradient);
    border-radius: 18px;
    color: var(--white);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.logo-sm {
    width: 56px;
    height: 56px;
    font-size: 20px;
    border-radius: 14px;
    margin-bottom: 16px;
}

.hero h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.tagline {
    font-size: 16px;
    color: var(--text-light);
    max-width: 520px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ---- Flash Messages ---- */

.flash-messages {
    margin-bottom: 24px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 8px;
}

.flash-error {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.flash-success {
    background: #f0fff4;
    color: #276749;
    border: 1px solid #9ae6b4;
}

/* ---- Form Progress ---- */

.form-progress {
    height: 3px;
    background: var(--border);
    border-radius: 3px;
    margin-bottom: 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient);
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease;
}

/* ---- Sample Mode ---- */

.sample-mode {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.btn-sample {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.25);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-sample:hover {
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.4);
}

.sample-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.form-legend {
    padding: 10px 32px;
    font-size: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

/* ---- Section Nav (Sticky Pills) ---- */

.section-nav {
    display: flex;
    gap: 6px;
    padding: 12px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    overflow-x: auto;
}

.nav-pill {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
}

.nav-pill:hover {
    color: var(--text-light);
    border-color: var(--text-muted);
}

.nav-pill.active {
    color: var(--white);
    background: var(--gradient);
    border-color: transparent;
}

.nav-pill.filled {
    color: var(--success);
    border-color: var(--success);
    background: #f0fff4;
}

.nav-pill.filled.active {
    color: var(--white);
    background: var(--gradient);
    border-color: transparent;
}

/* ---- Form Sections (Accordion) ---- */

.survey-form {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 0;
    overflow: hidden;
}

.form-section {
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
    border-bottom: none;
}

.accordion-section .section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 32px;
}

.accordion-section.open .section-body {
    max-height: 1200px;
    padding: 0 32px 28px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 32px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.section-header:hover {
    background: #fafbfc;
}

.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--gradient);
    color: var(--white);
    font-size: 12px;
    font-weight: 700;
    border-radius: 8px;
    flex-shrink: 0;
}

.section-header h2 {
    font-size: 17px;
    font-weight: 600;
    color: #1a202c;
    flex: 1;
}

.accordion-arrow {
    color: var(--text-muted);
    font-size: 14px;
    transition: transform 0.3s;
    flex-shrink: 0;
}

.accordion-section.open .accordion-arrow {
    transform: rotate(180deg);
}

/* Section Next Button */

.section-next {
    margin-top: 20px;
    text-align: right;
}

.btn-next {
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary);
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-next:hover {
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.3);
}

/* ---- Fields ---- */

.field {
    margin-bottom: 18px;
}

.field:last-child {
    margin-bottom: 0;
}

.field-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
}

.field-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.required {
    color: var(--primary);
}

.optional-tag {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.field-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}

input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23718096' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

::placeholder {
    color: var(--text-muted);
}

/* ---- Form Actions ---- */

.form-actions {
    padding: 24px 32px 28px;
    text-align: center;
}

.btn-generate {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 36px;
    font-size: 16px;
    font-weight: 600;
    color: var(--white);
    background: var(--gradient);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-generate:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-generate:active {
    transform: translateY(0);
}

.btn-generate:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 18px;
}

.form-note {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 10px;
}

/* ---- Loading Overlay ---- */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.96);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-content h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 8px;
}

.loading-status {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 24px;
}

.loading-steps {
    text-align: left;
}

.loading-steps .step {
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-muted);
    border-left: 2px solid var(--border);
    padding-left: 16px;
    margin-left: 8px;
    transition: color 0.3s, border-color 0.3s;
}

.loading-steps .step.active {
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 500;
}

.loading-steps .step.done {
    color: var(--success);
    border-left-color: var(--success);
}

/* ---- Completion Page ---- */

.completion-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 40px 32px;
    text-align: center;
    margin-bottom: 24px;
}

.completion-icon {
    width: 64px;
    height: 64px;
    background: #f0fff4;
    color: var(--success);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
}

.completion-card h2 {
    font-size: 22px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 4px;
}

.completion-subtitle {
    color: var(--text-light);
    font-size: 15px;
    margin-bottom: 24px;
}

.plan-details {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 20px 24px;
    margin-bottom: 28px;
    text-align: left;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.detail-row:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.detail-label {
    color: var(--text-light);
}

.detail-value {
    font-weight: 500;
    color: var(--text);
}

.completion-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    color: var(--white);
    background: var(--gradient);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 500;
    color: var(--primary);
    background: transparent;
    text-decoration: none;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    cursor: pointer;
    font-family: inherit;
}

.btn-secondary:hover {
    background: rgba(102, 126, 234, 0.06);
    border-color: rgba(102, 126, 234, 0.5);
}

/* ---- Email Section ---- */

.email-section {
    border-top: 1px solid var(--border);
    padding-top: 24px;
    margin-bottom: 24px;
    text-align: left;
}

.email-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 12px;
}

.email-input-group {
    display: flex;
    gap: 8px;
}

.email-input-group input[type="email"] {
    flex: 1;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s;
}

.email-input-group input[type="email"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.btn-send {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--white);
    background: var(--gradient);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.completion-next {
    text-align: left;
    border-top: 1px solid var(--border);
    padding-top: 24px;
}

.completion-next h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 12px;
}

.completion-next ol {
    padding-left: 20px;
    color: var(--text-light);
    font-size: 14px;
}

.completion-next li {
    margin-bottom: 6px;
}

/* ---- Admin Dashboard ---- */

.admin-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px 32px;
    text-align: center;
    flex: 1;
}

.stat-number {
    font-size: 36px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}

.admin-table-wrap {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
}

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

.admin-table th {
    background: #1a202c;
    color: var(--white);
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
}

.admin-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

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

.admin-table tr:hover {
    background: #f7fafc;
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-completed {
    background: #f0fff4;
    color: #276749;
}

.status-generating {
    background: #ebf8ff;
    color: #2b6cb0;
}

.btn-sm {
    display: inline-block;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    background: rgba(102, 126, 234, 0.08);
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-sm:hover {
    background: rgba(102, 126, 234, 0.15);
}

.empty-state {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 48px 32px;
    text-align: center;
    margin-bottom: 24px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ---- Loading / Progress Page ---- */

.loading-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 48px 32px;
    text-align: center;
    margin-bottom: 24px;
}

.loading-card h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 4px;
}

.loading-subtitle {
    color: var(--text-light);
    font-size: 15px;
    margin-bottom: 32px;
}

.progress-stages {
    text-align: left;
    max-width: 360px;
    margin: 0 auto 28px;
}

.stage {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    font-size: 14px;
    color: var(--text-muted);
    transition: color 0.3s;
}

.stage-icon {
    font-size: 10px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.stage.active {
    color: var(--primary);
    font-weight: 500;
}

.stage.active .stage-icon {
    color: var(--primary);
    animation: pulse 1.2s ease-in-out infinite;
}

.stage.done {
    color: var(--success);
}

.stage.done .stage-icon::after {
    content: "\2713";
}

.stage.done .stage-icon {
    font-size: 0;
}

.stage.done .stage-icon::after {
    font-size: 14px;
    font-weight: 700;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.loading-meta {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 13px;
    color: var(--text-muted);
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.elapsed-time strong {
    color: var(--text);
}

.loading-error {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 48px 32px;
    text-align: center;
    margin-bottom: 24px;
}

.error-icon {
    width: 56px;
    height: 56px;
    background: #fff5f5;
    color: #c53030;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

.loading-error h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 8px;
}

.loading-error p {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 20px;
}

/* ---- Misc ---- */

.back-link {
    text-align: center;
    margin-bottom: 24px;
}

.back-link a {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

.back-link a:hover {
    text-decoration: underline;
}

footer {
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

footer p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ---- Responsive ---- */

@media (max-width: 640px) {
    .container {
        padding: 24px 16px 40px;
    }

    .hero h1 {
        font-size: 22px;
    }

    .section-header {
        padding: 16px 20px;
    }

    .accordion-section.open .section-body {
        padding: 0 20px 24px;
    }

    .accordion-section .section-body {
        padding: 0 20px;
    }

    .form-actions {
        padding: 20px;
    }

    .field-group {
        grid-template-columns: 1fr;
    }

    .completion-card {
        padding: 28px 20px;
    }

    .completion-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-download,
    .btn-secondary {
        justify-content: center;
    }

    .section-nav {
        padding: 10px 16px;
    }

    .nav-pill {
        font-size: 12px;
        padding: 5px 10px;
    }
}
