/* Modern Form Layouts - Replaces Table-Based Forms
 * Uses CSS Grid and Flexbox for responsive, accessible forms
 */

/* ========================================
 * Form Container
 * ======================================== */
.form-container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 20px 40px;
    box-sizing: border-box;
}

/* ========================================
 * Form Sections
 * ======================================== */
.form-section {
    margin-bottom: 30px;
}

.form-section h2 {
    color: var(--stf-text-light);
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--stf-border);
}

/* ========================================
 * Form Fields - Modern Grid Layout
 * ======================================== */
.form-field {
    display: grid;
    grid-template-columns: 175px 5px 1fr;
    gap: 0;
    margin-bottom: 15px;
    align-items: center;
}

.form-field-label {
    text-align: right;
    padding-right: 10px;
    color: var(--stf-text-light);
    font-weight: bold;
    font-size: 12px;
}

.form-field-separator {
    text-align: center;
    color: var(--stf-text-light);
    font-weight: bold;
    padding: 0 5px;
}

.form-field-input {
    padding-left: 10px;
}

.form-field-input input[type="text"],
.form-field-input input[type="email"],
.form-field-input input[type="password"],
.form-field-input select,
.form-field-input textarea {
    width: 100%;
    max-width: 400px;
    padding: 8px;
    background-color: #111111;
    border: 1px solid var(--stf-border);
    color: var(--stf-text-light);
    font-size: 12px;
    box-sizing: border-box;
}

.form-field-input input:focus,
.form-field-input select:focus,
.form-field-input textarea:focus {
    outline: 2px solid var(--stf-primary);
    outline-offset: 2px;
    border-color: var(--stf-primary);
}

.form-field-input textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

/* ========================================
 * Form Intro
 * ======================================== */
.form-intro {
    background-color: rgba(201, 28, 31, 0.1);
    border-left: 4px solid #C91C1F;
    padding: 15px 20px;
    margin-bottom: 30px;
    border-radius: 4px;
}

.form-intro p {
    margin: 10px 0;
    color: var(--stf-text-light);
    font-size: 14px;
    line-height: 1.6;
}

.form-intro p:first-child {
    margin-top: 0;
}

.form-intro p:last-child {
    margin-bottom: 0;
}

.form-intro a {
    color: #C91C1F;
    text-decoration: underline;
}

.form-intro a:hover {
    color: #ff4447;
}

/* ========================================
 * Form Progress Bar
 * ======================================== */
.form-progress {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 10px 15px;
    margin-bottom: 30px;
    position: relative;
    height: 40px;
    display: flex;
    align-items: center;
}

.progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #C91C1F 0%, #ff4447 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    position: relative;
    z-index: 1;
    color: var(--stf-text-light);
    font-weight: bold;
    font-size: 14px;
    margin-left: auto;
}

/* ========================================
 * Form Labels and Required Fields
 * ======================================== */
.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--stf-text-light);
    font-weight: bold;
    font-size: 14px;
}

.form-label.required::after {
    content: " *";
    color: #C91C1F;
}

.field-hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

.field-hint.preface {
    margin-bottom: 8px;
}

.section-intro {
    color: var(--lcars-blue);
    margin-bottom: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.optional-note {
    color: var(--lcars-gold);
    font-style: italic;
    margin-bottom: 20px;
}

.toggle-input {
    margin-top: 10px;
    display: none;
}

.input-narrow {
    max-width: 150px;
}

.form-divider {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid var(--lcars-blue);
}

.form-group.centered {
    text-align: center;
    margin-top: 30px;
}

.is-hidden {
    display: none;
}

.field-error {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #ff4447;
    font-weight: bold;
}

.field-error:empty {
    display: none;
}

/* ========================================
 * Form Grid Layouts
 * ======================================== */
.form-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.form-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ========================================
 * Form Groups
 * ======================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* ========================================
 * Form Inputs
 * ======================================== */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    background-color: #111111;
    border: 2px solid var(--stf-border);
    border-radius: 4px;
    color: var(--stf-text-light);
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.3s ease, outline 0.3s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #C91C1F;
    box-shadow: 0 0 0 3px rgba(201, 28, 31, 0.2);
}

.form-input:invalid:not(:placeholder-shown),
.form-select:invalid:not(:placeholder-shown) {
    border-color: #ff4447;
}

.form-input:valid:not(:placeholder-shown),
.form-select:valid:not(:placeholder-shown) {
    border-color: #4CAF50;
}

.form-input.error,
.form-input:invalid:not(:placeholder-shown):not(:focus) {
    border-color: #ff4447;
    box-shadow: 0 0 0 3px rgba(255, 68, 71, 0.2);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
}

.form-select {
    cursor: pointer;
    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='%23ffffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

/* ========================================
 * Form Section Titles
 * ======================================== */
.form-section-title {
    background-color: #C91C1F;
    color: white;
    padding: 12px 20px;
    margin: 30px 0 20px 0;
    border-radius: 4px;
    font-size: 18px;
    font-weight: bold;
}

.form-section:first-child .form-section-title {
    margin-top: 0;
}

/* ========================================
 * Username Check
 * ======================================== */
.username-check {
    margin-top: 5px;
    font-size: 12px;
}

.username-check.checking {
    color: rgba(255, 255, 255, 0.6);
}

.username-check.available {
    color: #4CAF50;
    font-weight: bold;
}

.username-check.unavailable {
    color: #ff4447;
    font-weight: bold;
}

/* ========================================
 * Form Buttons
 * ======================================== */
.form-actions {
    margin-top: 30px;
    text-align: center;
}

.form-actions .button,
.form-actions input[type="submit"],
.form-actions button {
    background-color: var(--stf-primary);
    color: var(--stf-bg-dark);
    border: none;
    padding: 12px 30px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: background-color 0.3s ease;
}

.form-actions .button:hover,
.form-actions input[type="submit"]:hover,
.form-actions button:hover {
    background-color: #ffb733;
}

.form-actions .button:active,
.form-actions input[type="submit"]:active,
.form-actions button:active {
    background-color: #e69405;
}

/* ========================================
 * Form Submit Button
 * ======================================== */
.form-button {
    background-color: #C91C1F;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    text-transform: uppercase;
    position: relative;
    min-width: 200px;
}

.form-button:hover {
    background-color: #ff4447;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(201, 28, 31, 0.3);
}

.form-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(201, 28, 31, 0.2);
}

.form-button:disabled {
    background-color: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.form-submit-button {
    background-color: #C91C1F;
}

.form-submit-button:hover:not(:disabled) {
    background-color: #ff4447;
}

.button-text,
.button-loader {
    display: inline-block;
}

.form-note {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 10px;
}

.form-note.highlight {
    color: var(--lcars-blue);
    margin-top: 0;
    margin-bottom: 15px;
}

/* ========================================
 * reCAPTCHA Container
 * ======================================== */
.form-recaptcha {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
}

.form-recaptcha .g-recaptcha {
    margin-bottom: 10px;
}

/* ========================================
 * Responsive Design
 * ======================================== */

/* Tablets and smaller */
@media (max-width: 768px) {
    .form-field {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    .form-field-label {
        text-align: left;
        padding-right: 0;
        padding-bottom: 5px;
    }
    
    .form-field-separator {
        display: none;
    }
    
    .form-field-input {
        padding-left: 0;
    }
    
    .form-field-input input[type="text"],
    .form-field-input input[type="email"],
    .form-field-input input[type="password"],
    .form-field-input select,
    .form-field-input textarea {
        max-width: 100%;
    }
}

/* Mobile phones */
@media (max-width: 600px) {
    .form-container {
        padding: 15px;
    }
    
    .form-section h2 {
        font-size: 16px;
    }
    
    .form-field {
        margin-bottom: 20px;
    }
}

/* ========================================
 * Timeline/Data Display (replaces table-based timelines)
 * ======================================== */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.timeline-item {
    display: grid;
    grid-template-columns: 80px 20px 1fr;
    gap: 10px;
    align-items: start;
}

.timeline-year {
    text-align: center;
    font-weight: bold;
    color: var(--stf-primary);
    font-size: 14px;
}

.timeline-separator {
    text-align: center;
    color: var(--stf-text-light);
    font-weight: bold;
}

.timeline-content {
    color: var(--stf-text-light);
    font-size: 12px;
    line-height: 1.6;
}

/* Data Table (for region page, etc.) */
.data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: 1px;
    background-color: var(--stf-border);
    margin: 20px 0;
    border: 1px solid var(--stf-border);
}

.data-grid-header {
    background-color: var(--stf-bg-darker);
    padding: 12px;
    font-weight: bold;
    color: var(--stf-text-light);
    text-align: center;
    font-size: 14px;
}

.data-grid-cell {
    background-color: var(--stf-bg-content);
    padding: 10px;
    color: var(--stf-text-light);
    font-size: 12px;
    vertical-align: top;
}

.data-grid-cell:first-child {
    text-align: center;
    font-weight: bold;
}

/* Responsive data grid */
@media (max-width: 768px) {
    .data-grid {
        grid-template-columns: 1fr;
    }
    
    .data-grid-header {
        display: none;
    }
    
    .data-grid-cell::before {
        content: attr(data-label) ": ";
        font-weight: bold;
        display: inline-block;
        min-width: 120px;
    }
    
    .timeline-item {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    .timeline-year {
        text-align: left;
    }
    
    .timeline-separator {
        display: none;
    }
}

/* ========================================
 * Legacy Table Support (for backward compatibility)
 * ======================================== */
table.pretty-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

table.pretty-table td {
    padding: 8px;
    vertical-align: middle;
}

/* Convert table-based forms to modern layout when ready */
.pretty-table .form-field {
    display: contents; /* Allows grid to work within table cells */
}

/* ========================================
 * Form Wizard Styles
 * ======================================== */
.form-wizard {
    position: relative;
}

.wizard-progress-container {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.wizard-step-indicators {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
}

.wizard-step-indicators::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background-color: rgba(255, 255, 255, 0.2);
    z-index: 0;
}

.step-indicator {
    position: relative;
    z-index: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--stf-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.step-indicator:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.step-indicator.active {
    background-color: #C91C1F;
    border-color: #C91C1F;
    color: white;
    box-shadow: 0 0 0 4px rgba(201, 28, 31, 0.3);
}

.step-indicator.complete {
    background-color: #4CAF50;
    border-color: #4CAF50;
    color: white;
}

.step-indicator.complete::after {
    content: '✓';
    font-size: 20px;
}

.wizard-steps {
    position: relative;
}

.wizard-step {
    display: none;
    animation: fadeIn 0.3s ease;
}

.wizard-step.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wizard-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--stf-border);
}

.wizard-nav-button {
    background-color: #C91C1F;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    text-transform: uppercase;
    min-width: 120px;
}

.wizard-nav-button:hover:not(:disabled) {
    background-color: #ff4447;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(201, 28, 31, 0.3);
}

.wizard-nav-button:disabled {
    background-color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.wizard-nav-button.btn-back {
    background-color: rgba(255, 255, 255, 0.1);
}

.wizard-nav-button.btn-back:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.2);
}

.wizard-nav-button.btn-submit {
    background-color: #4CAF50;
}

.wizard-nav-button.btn-submit:hover:not(:disabled) {
    background-color: #66BB6A;
}

.step-progress-text {
    color: var(--stf-text-light);
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    margin-top: 10px;
}

/* Character Counter */
.character-counter {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-align: right;
}

.character-counter.warning {
    color: #ff9800;
}

.character-counter.error {
    color: #ff4447;
}

/* Review Summary */
.review-summary {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.review-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.review-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.review-section h3 {
    color: #C91C1F;
    font-size: 18px;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.review-item {
    margin-bottom: 10px;
    padding: 8px 0;
}

.review-item strong {
    color: var(--stf-text-light);
    display: inline-block;
    min-width: 150px;
    margin-right: 10px;
}

.review-item span {
    color: rgba(255, 255, 255, 0.8);
}

.review-edit-link {
    color: #C91C1F;
    text-decoration: none;
    margin-left: 10px;
    font-size: 12px;
}

.review-edit-link:hover {
    text-decoration: underline;
}

/* Validation States */
.form-input.valid,
.form-select.valid,
.form-textarea.valid {
    border-color: #4CAF50;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%234CAF50' d='M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.form-input.invalid,
.form-select.invalid,
.form-textarea.invalid {
    border-color: #ff4447;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%23ff4447' d='M8 0a8 8 0 100 16A8 8 0 008 0zM4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* Responsive Wizard */
@media (max-width: 768px) {
    .wizard-step-indicators {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .step-indicator {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .wizard-navigation {
        flex-direction: column;
        gap: 10px;
    }
    
    .wizard-nav-button {
        width: 100%;
    }
    
    .review-item strong {
        display: block;
        margin-bottom: 5px;
    }
}

