/**
 * Canada PR Application Form - Styles
 * Professional, responsive design
 */

/* ========================================
   CSS Variables & Reset
   ======================================== */

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

:root {
    --primary-red: #c62828;
    --primary-blue: #1565c0;
    --success-green: #2e7d32;
    --warning-orange: #f57c00;
    --text-dark: #212121;
    --text-light: #757575;
    --bg-light: #f5f5f5;
    --white: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.15);
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
}

/* ========================================
   Header
   ======================================== */

.header {
    background: linear-gradient(135deg, var(--primary-red) 0%, #d32f2f 100%);
    color: var(--white);
    padding: 2rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.header .flag {
    font-size: 3rem;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* ========================================
   Progress Bar
   ======================================== */

.progress-container {
    background: var(--white);
    padding: 2rem;
    margin: 2rem auto;
    max-width: 1200px;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    position: relative;
}

.progress-line {
    position: absolute;
    top: 25px;
    left: 50px;
    right: 50px;
    height: 4px;
    background: var(--border-color);
    z-index: 0;
}

.progress-line-fill {
    height: 100%;
    background: var(--primary-blue);
    width: 0%;
    transition: width 0.3s ease;
}

.step {
    position: relative;
    z-index: 1;
    text-align: center;
    flex: 1;
}

.step-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--white);
    border: 4px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.5rem;
    font-weight: 600;
    color: var(--text-light);
    transition: all 0.3s ease;
}

.step.active .step-circle {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: var(--white);
    transform: scale(1.1);
}

.step.completed .step-circle {
    background: var(--success-green);
    border-color: var(--success-green);
    color: var(--white);
}

.step.completed .step-circle::before {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
}

.step-label {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

.step.active .step-label {
    color: var(--primary-blue);
    font-weight: 600;
}

/* ========================================
   Auto-save Indicator
   ======================================== */

.autosave-indicator {
    position: fixed;
    top: 100px;
    right: 20px;
    background: var(--white);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    box-shadow: var(--shadow);
    display: none;
    align-items: center;
    gap: 0.5rem;
    z-index: 99;
    animation: slideIn 0.3s ease;
}

.autosave-indicator.show {
    display: flex;
}

.autosave-indicator i {
    color: var(--success-green);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   Form Container & Sections
   ======================================== */

.form-container {
    max-width: 1200px;
    margin: 0 auto 2rem;
    padding: 0 2rem;
}

.form-section {
    background: var(--white);
    padding: 2.5rem;
    margin-bottom: 2rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: none;
}

.form-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    font-size: 2rem;
    color: var(--primary-red);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--primary-red);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-subtitle {
    font-size: 1.4rem;
    color: var(--primary-blue);
    margin: 2rem 0 1rem;
    font-weight: 600;
}

/* ========================================
   Form Elements
   ======================================== */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.95rem;
}

.required {
    color: var(--primary-red);
    font-weight: 700;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
    width: 100%;
    background: var(--white);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
}

input:invalid:not(:focus),
select:invalid:not(:focus),
textarea:invalid:not(:focus) {
    border-color: var(--warning-orange);
}

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

select {
    cursor: pointer;
}

input[readonly] {
    background: #f9f9f9;
    cursor: not-allowed;
}

/* ========================================
   Dynamic Tables
   ======================================== */

.dynamic-table {
    margin: 1.5rem 0 2rem;
}

.table-responsive {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background: var(--white);
    border-radius: 5px;
    overflow: hidden;
}

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

th {
    background: var(--primary-blue);
    color: var(--white);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    background: var(--white);
}

td input,
td select,
td textarea {
    padding: 0.5rem;
    font-size: 0.9rem;
}

tbody tr:hover {
    background: #f9f9f9;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-blue);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: #1976d2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.3);
}

.btn-secondary {
    background: var(--text-light);
    color: var(--white);
}

.btn-secondary:hover:not(:disabled) {
    background: #616161;
}

.btn-success {
    background: var(--success-green);
    color: var(--white);
    font-size: 1.1rem;
    padding: 1rem 2.5rem;
}

.btn-success:hover:not(:disabled) {
    background: #388e3c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.btn-add-row {
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--success-green);
    color: var(--white);
    font-family: inherit;
}

.btn-add-row:hover {
    background: #388e3c;
    transform: translateY(-1px);
}

.btn-remove-row {
    background: var(--primary-red);
    color: var(--white);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-remove-row:hover {
    background: #d32f2f;
}

/* ========================================
   Form Navigation
   ======================================== */

.form-navigation {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

/* ========================================
   Info & Warning Boxes
   ======================================== */

.info-box,
.warning-box {
    padding: 1.25rem;
    margin: 1.5rem 0;
    border-radius: 5px;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    line-height: 1.6;
}

.info-box {
    background: #e3f2fd;
    border-left: 4px solid var(--primary-blue);
    color: #01579b;
}

.info-box i {
    color: var(--primary-blue);
    margin-top: 0.2rem;
}

.warning-box {
    background: #fff3e0;
    border-left: 4px solid var(--warning-orange);
    color: #e65100;
}

.warning-box i {
    color: var(--warning-orange);
    margin-top: 0.2rem;
}

/* ========================================
   Declaration Box
   ======================================== */

.declaration-box {
    background: #f9f9f9;
    padding: 2rem;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    margin: 1.5rem 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* ========================================
   Modal
   ======================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    padding: 2.5rem;
    border-radius: 10px;
    max-width: 550px;
    width: 90%;
    text-align: center;
    animation: modalFadeIn 0.3s ease;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-icon {
    font-size: 5rem;
    color: var(--success-green);
    margin-bottom: 1rem;
    animation: checkBounce 0.6s ease;
}

@keyframes checkBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.modal-title {
    font-size: 2rem;
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-weight: 700;
}

.application-id {
    background: var(--bg-light);
    padding: 1.25rem;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-blue);
    margin: 1.5rem 0;
    border: 2px dashed var(--primary-blue);
}

/* ========================================
   Loading Overlay
   ======================================== */

.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading.show {
    display: flex;
}

.spinner {
    border: 6px solid var(--border-color);
    border-top: 6px solid var(--primary-blue);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: var(--white);
    font-size: 1.1rem;
    font-weight: 500;
}

/* ========================================
   Toast Notification
   ======================================== */

.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: var(--white);
    padding: 1rem 2rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 998;
    transition: bottom 0.3s ease;
}

.toast.show {
    bottom: 30px;
}

.toast i {
    color: var(--success-green);
    font-size: 1.2rem;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 968px) {
    .header h1 {
        font-size: 2rem;
    }

    .header .flag {
        font-size: 2rem;
    }

    .section-title {
        font-size: 1.6rem;
    }

    .section-subtitle {
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 1.6rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .header p {
        font-size: 1rem;
    }

    .progress-steps {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .progress-line {
        display: none;
    }

    .step {
        flex: 0 0 calc(50% - 0.5rem);
    }

    .form-navigation {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .form-section {
        padding: 1.5rem;
    }

    .table-responsive {
        padding: 1rem;
    }

    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.5rem 0.3rem;
    }

    td input,
    td select {
        font-size: 0.85rem;
        padding: 0.4rem;
    }

    .autosave-indicator {
        right: 10px;
        top: 80px;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 0;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .header .flag {
        font-size: 1.5rem;
    }

    .progress-container {
        padding: 1rem;
    }

    .step {
        flex: 0 0 100%;
    }

    .form-container {
        padding: 0 1rem;
    }

    .form-section {
        padding: 1rem;
    }

    .section-title {
        font-size: 1.3rem;
    }

    .section-subtitle {
        font-size: 1.1rem;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .modal-title {
        font-size: 1.5rem;
    }

    .application-id {
        font-size: 1.2rem;
    }

    table {
        font-size: 0.75rem;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .header,
    .progress-container,
    .form-navigation,
    .btn,
    .autosave-indicator,
    .modal,
    .loading,
    .toast {
        display: none !important;
    }

    .form-section {
        display: block !important;
        page-break-after: always;
        box-shadow: none;
        padding: 1rem;
    }

    body {
        background: var(--white);
    }

    .form-container {
        max-width: 100%;
    }
}

/* ========================================
   Utility Classes
   ======================================== */

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}
