/* ===== RESET & VARIABLES ===== */
:root {
    --wa-green: #25D366;
    --wa-green-dark: #128C7E;
    --bg-color: #F0F2F5;
    --card-bg: #FFFFFF;
    --text-primary: #1C1E21;
    --text-secondary: #65676B;
    --border-color: #E4E6EB;
    --error-color: #FA3E3E;
    --focus-ring: rgba(37, 211, 102, 0.4);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
}

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

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

/* Visually Hidden for screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== LAYOUT & STRUCTURE ===== */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== HEADER ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.logo-text span {
    color: var(--text-secondary);
    font-weight: 500;
}

.lang-switcher {
    display: flex;
    gap: 8px;
    align-items: center;
}

.flag-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    opacity: 0.5;
    transition: all 0.2s ease;
    padding: 4px;
    border-radius: 4px;
}

.flag-btn:hover {
    opacity: 0.8;
    background-color: rgba(0,0,0,0.05);
}

.flag-btn.active {
    opacity: 1;
    transform: scale(1.1);
    background-color: var(--focus-ring);
}

/* ===== MAIN HERO & FORM ===== */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 0 48px;
}

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

h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -1px;
    line-height: 1.2;
}

h2 {
    font-size: 1.125rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.form-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    text-align: left;
    transition: transform 0.3s ease;
}

.input-group {
    margin-bottom: 24px;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.phone-input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.ddi-container {
    position: relative;
    width: 35%;
}

.number-container {
    flex: 1;
}

.ddi-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 250px;
    max-height: 200px;
    overflow-y: auto;
    background: #FFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 10;
    margin-top: 4px;
}

.ddi-option {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.ddi-option:hover {
    background-color: var(--bg-color);
}

.ddi-option .flag {
    font-size: 1.2rem;
}

.ddi-option .code {
    font-weight: 700;
    color: var(--text-primary);
}

.ddi-option .name {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.ddi-success {
    border-color: var(--wa-green) !important;
    background-color: rgba(37, 211, 102, 0.05) !important;
}

input[type="tel"],
input[type="text"],
textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: all 0.2s ease;
    background-color: var(--bg-color);
}

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

input[type="tel"]:focus,
input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--wa-green);
    background-color: #fff;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

input[type="tel"]::placeholder,
input[type="text"]::placeholder,
textarea::placeholder {
    color: #9CA3AF;
}

.error-msg {
    display: block;
    color: var(--error-color);
    font-size: 0.8125rem;
    margin-top: 6px;
    min-height: 18px;
}

.message-toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.format-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.format-btn:hover {
    background-color: rgba(37, 211, 102, 0.1);
    color: var(--wa-green-dark);
    border-color: var(--wa-green);
}

.format-btn i { font-style: italic; }
.format-btn b { font-weight: bold; }
.format-btn s { text-decoration: line-through; }
.format-btn.mono { font-family: monospace; font-weight: 500; font-size: 13px; }

.btn-primary {
    width: 100%;
    background-color: var(--wa-green);
    color: #FFF;
    border: none;
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--wa-green-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(18, 140, 126, 0.4);
    outline: none;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(18, 140, 126, 0.3);
}

.btn-secondary {
    width: 100%;
    margin-top: 12px;
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.btn-secondary:hover, .btn-secondary:focus {
    background-color: var(--bg-color);
    color: var(--text-primary);
    border-color: #D1D5DB;
    outline: none;
}

.btn-icon {
    width: 24px;
    height: 24px;
}

/* ===== INSTRUCTIONS ===== */
.instructions {
    margin-top: 48px;
    text-align: center;
}

.instructions h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.step-item {
    background: var(--card-bg);
    padding: 24px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.step-num {
    width: 32px;
    height: 32px;
    background-color: rgba(37, 211, 102, 0.1);
    color: var(--wa-green-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.step-item p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ===== FOOTER ===== */
footer {
    text-align: center;
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer-links {
    margin-bottom: 12px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--wa-green-dark);
}

.separator {
    color: var(--border-color);
    margin: 0 8px;
}

.copyright {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.history-chip {
    display: inline-flex;
    align-items: center;
    background-color: #E5E7EB;
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.history-chip:hover {
    background-color: #D1D5DB;
    border-color: #9CA3AF;
}

/* ===== LEGAL PAGES ===== */
.legal-page {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 40px;
}

.legal-page h1 {
    font-size: 1.75rem;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--bg-color);
}

.legal-page h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    margin-top: 28px;
    text-align: left;
}

.legal-page p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.7;
}

.legal-page ul {
    margin: 12px 0 12px 24px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.8;
}

.legal-page code {
    background: var(--bg-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
}

.back-link {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--wa-green-dark);
    text-decoration: none;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--wa-green);
}

/* ===== RESPONSIVE ===== */

/* h2 moved below form — needs top margin */
.hero-section > h2 {
    margin-top: 28px;
}

@media (max-width: 768px) {
    header {
        padding: 12px 0;
    }

    main {
        padding: 12px 0 32px;
    }

    .hero-section {
        margin-bottom: 24px;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }

    h2 {
        font-size: 1rem;
        margin-bottom: 16px;
    }

    .hero-section > h2 {
        margin-top: 20px;
    }

    .form-card {
        padding: 20px 16px;
    }

    .input-group {
        margin-bottom: 14px;
    }

    label {
        font-size: 0.8125rem;
        margin-bottom: 4px;
    }

    input[type="tel"],
    input[type="text"] {
        padding: 10px 12px;
        font-size: 0.9375rem;
    }

    textarea {
        padding: 10px 12px;
        min-height: 60px;
        font-size: 0.9375rem;
    }

    .message-toolbar {
        margin-bottom: 6px;
    }

    .format-btn {
        padding: 4px 10px;
        font-size: 13px;
    }

    .btn-primary {
        padding: 14px;
        font-size: 1rem;
        min-height: 48px;
    }

    .btn-secondary {
        padding: 10px;
        font-size: 0.9375rem;
        margin-top: 8px;
        min-height: 44px;
    }

    .phone-input-group {
        gap: 6px;
    }

    .ddi-container {
        width: 38%;
    }

    .steps-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .step-item {
        padding: 16px 12px;
    }

    .instructions {
        margin-top: 32px;
    }
}

@media (max-width: 380px) {
    h1 {
        font-size: 1.3rem;
    }

    .form-card {
        padding: 16px 12px;
    }

    .input-group {
        margin-bottom: 10px;
    }
}
