/* ===== CSS CUSTOM PROPERTIES (USMC COLOR PALETTE) ===== */
:root {
    --usmc-scarlet: #CE1126;
    --usmc-gold: #FFC72C;
    --usmc-navy: #003F87;
    --usmc-white: #FFFFFF;

    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== PASSWORD PROTECTION ===== */
.password-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.password-overlay.hidden {
    display: none;
}

.password-modal {
    background: white;
    padding: 3rem;
    border-radius: 12px;
    border: 4px solid var(--usmc-scarlet);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.usmc-emblem-large {
    background: var(--usmc-scarlet);
    color: var(--usmc-gold);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    padding: 1rem 2rem;
    border-radius: 8px;
    display: inline-block;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-lg);
    letter-spacing: 4px;
}

.password-modal h2 {
    color: var(--gray-900);
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.password-modal p {
    color: var(--gray-600);
    margin-bottom: 2rem;
}

.password-modal form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.password-modal input {
    padding: 0.875rem 1rem;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    text-align: center;
    font-family: 'Inter', sans-serif;
}

.password-modal input:focus {
    outline: none;
    border-color: var(--usmc-scarlet);
    box-shadow: 0 0 0 3px rgba(206, 17, 38, 0.1);
}

.password-modal button {
    padding: 0.875rem 1.5rem;
    background: var(--usmc-scarlet);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.password-modal button:hover {
    background: #A00D18;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.password-error {
    color: var(--usmc-scarlet);
    font-size: 0.875rem;
    min-height: 1.25rem;
    margin: 0;
}

/* ===== HEADER ===== */
.app-header {
    background: linear-gradient(135deg, var(--usmc-scarlet) 0%, #A00D18 100%);
    color: var(--usmc-white);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.usmc-emblem {
    width: 60px;
    height: 60px;
    background-color: var(--usmc-gold);
    color: var(--usmc-scarlet);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.5rem;
    font-weight: bold;
    border: 3px solid var(--usmc-white);
    box-shadow: var(--shadow-md);
}

.header-text h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.875rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.5px;
}

.header-text p {
    font-size: 0.875rem;
    opacity: 0.95;
    margin: 0;
    font-weight: 500;
}

.header-right .semper-fi {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    font-style: italic;
    color: var(--usmc-gold);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ===== MAIN CONTAINER (SPLIT SCREEN) ===== */
.main-container {
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 40% 60%;
    gap: 2rem;
    padding: 2rem;
    min-height: calc(100vh - 120px);
}

/* ===== FORM SECTION (LEFT 40%) ===== */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 160px);
    padding-right: 1rem;
}

/* Custom scrollbar */
.form-section::-webkit-scrollbar {
    width: 8px;
}

.form-section::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 4px;
}

.form-section::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

.form-section::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

.form-header {
    margin-bottom: 0.5rem;
}

.form-header h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--usmc-navy);
    margin-bottom: 0.5rem;
}

.form-header p {
    color: var(--gray-600);
    font-size: 0.95rem;
}

/* ===== FORM CARDS ===== */
.form-card {
    background-color: var(--usmc-white);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.form-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    background: linear-gradient(135deg, var(--usmc-navy) 0%, #002A5C 100%);
    color: var(--usmc-white);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.card-header:hover {
    background: linear-gradient(135deg, #002A5C 0%, var(--usmc-navy) 100%);
}

.card-header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.card-icon {
    width: 24px;
    height: 24px;
    stroke: var(--usmc-gold);
    flex-shrink: 0;
}

.card-header h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.card-chevron {
    width: 20px;
    height: 20px;
    stroke: var(--usmc-white);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-left: auto;
}

.form-card.collapsed .card-chevron {
    transform: rotate(-90deg);
}

.card-body {
    padding: 1.5rem;
    overflow: visible;
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.3s ease;
}

.form-card:not(.collapsed) .card-body {
    max-height: none;
}

.form-card.collapsed .card-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
}

/* ===== FORM GROUPS ===== */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group select,
.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    background-color: var(--usmc-white);
    font-family: 'Inter', sans-serif;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group textarea {
    resize: vertical;
    min-height: 200px;
    line-height: 1.6;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--usmc-scarlet);
    box-shadow: 0 0 0 3px rgba(206, 17, 38, 0.1);
}

.form-group select:hover,
.form-group input:hover,
.form-group textarea:hover {
    border-color: var(--gray-400);
}

/* ===== BUILDER BUTTONS ===== */
.builder-btn {
    width: 100%;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--usmc-navy);
    background-color: var(--usmc-white);
    color: var(--usmc-navy);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.builder-btn:hover {
    background-color: var(--usmc-navy);
    color: var(--usmc-white);
}

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

.selection-preview {
    margin-top: 0.75rem;
    padding: 0.875rem;
    background-color: var(--gray-50);
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-placeholder-text {
    color: var(--gray-500);
    font-style: italic;
    font-size: 0.875rem;
}

/* ===== ACTION BUTTONS ===== */
.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn {
    flex: 1;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Montserrat', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--usmc-gold) 0%, #E6A800 100%);
    color: var(--gray-900);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #E6A800 0%, var(--usmc-gold) 100%);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--usmc-scarlet) 0%, #A00D18 100%);
    color: var(--usmc-white);
    box-shadow: var(--shadow-md);
}

.btn-secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, #A00D18 0%, var(--usmc-scarlet) 100%);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.btn-secondary:disabled {
    background: var(--gray-300);
    color: var(--gray-500);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ===== PREVIEW SECTION (RIGHT 60%) ===== */
.preview-section {
    background-color: var(--usmc-white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-200);
    position: sticky;
    top: 120px;
    max-height: calc(100vh - 140px);
    overflow: hidden;
}

.preview-header {
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--usmc-gold);
    padding-bottom: 1rem;
}

.preview-header h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--usmc-navy);
    margin-bottom: 0.25rem;
}

.preview-header p {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.preview-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-color: var(--gray-50);
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    padding: 2rem;
    overflow: auto;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--gray-400);
    text-align: center;
}

.placeholder-icon {
    width: 64px;
    height: 64px;
    stroke: var(--gray-300);
}

.preview-placeholder p {
    font-size: 1rem;
    font-weight: 500;
}

/* ===== SHADOWBOX PREVIEW STYLES ===== */
.shadowbox-preview {
    position: relative;
    width: 100%;
    max-width: 650px;
    aspect-ratio: 11 / 17;
    margin: 0 auto;
    background-color: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    overflow: hidden;
}

/* Top Banner */
.shadowbox-banner {
    position: absolute;
    top: 2.94%;
    left: 4.55%;
    width: 90.9%;
    height: 9.59%;
    background: linear-gradient(to bottom, #FFD700 0%, #F4C430 100%);
    border: 3px solid #000;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2), inset 0 -2px 4px rgba(255,255,255,0.3);
}

.shadowbox-banner-text {
    font-family: 'UnifrakturMaguntia', cursive;
    font-size: 1.5vw;
    color: #000;
    text-align: center;
    font-weight: bold;
}

/* Left Column with Ranks */
.vertical-column {
    position: absolute;
    top: 12.53%;
    left: 4.55%;
    width: 14.5%;
    height: 74.71%;
    display: flex;
    flex-direction: column;
}

.column-base {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

.column-stripe {
    position: absolute;
    top: 0.5%;
    left: 36%;
    width: 28%;
    height: 99%;
    border-radius: 3px;
}

.rank-images-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    padding: 8px;
    z-index: 10;
}

.rank-image {
    width: 85%;
    height: auto;
    object-fit: contain;
    max-height: calc(100% / 10);
}

/* Main Text Area */
.main-text-area {
    position: absolute;
    top: 12.53%;
    left: 50%;
    transform: translateX(-50%);
    width: 53.5%;
    height: 64.71%;
    padding: 20px;
    font-family: 'UnifrakturMaguntia', cursive;
    font-size: 1.1vw;
    line-height: 1.35;
    overflow-y: hidden;
    color: #000;
    text-align: center;
}

.main-text-area p {
    margin-bottom: 10px;
}

.highlighted-name {
    background-color: #000;
    color: #fff;
    padding: 4px 8px;
    display: inline-block;
    margin: 5px 0;
}

/* Right Column Badges */
.right-badges {
    position: absolute;
    top: 12.53%;
    right: 4.55%;
    width: 12%;
    height: 64.71%;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    padding: 10px 5px;
}

.badge-placeholder {
    width: 100%;
    aspect-ratio: 1;
    background-color: #ddd;
    border-radius: 50%;
    border: 2px solid #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6vw;
    color: #666;
    text-align: center;
}

/* Signature Area */
.signature-area {
    position: absolute;
    top: 87.24%;
    left: 4.55%;
    width: 14.5%;
    height: 8%;
    padding: 5px;
}

.signature-name {
    font-family: 'Parisienne', cursive;
    font-size: 1.3vw;
    color: #000;
    margin-bottom: 1px;
    line-height: 1.1;
}

.signature-title {
    font-family: 'UnifrakturMaguntia', cursive;
    font-size: 0.6vw;
    color: #000;
    margin-bottom: 1px;
    line-height: 1.1;
}

.signature-stars {
    font-size: 0.8vw;
    color: #000;
    line-height: 1.1;
}

.signature-icon {
    width: 80%;
    height: auto;
    margin-top: 5px;
}

/* Ribbons Area */
.ribbons-area {
    position: absolute;
    top: 77.12%;
    left: 50%;
    transform: translateX(-50%);
    width: 53.5%;
    height: 6%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
}

.ribbon-row {
    display: flex;
    gap: 2px;
    justify-content: center;
}

.ribbon-placeholder {
    width: 2.2vw;
    height: 0.75vw;
    background: linear-gradient(to right, #FF0000, #00FF00, #0000FF);
    border: 1px solid #000;
}

/* Marksmanship Badges Area */
.marksmanship-area {
    position: absolute;
    top: 84%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.marksmanship-badge {
    width: 2.5vw;
    height: 3.5vw;
    object-fit: contain;
}

/* Medals Area */
.medals-area {
    position: absolute;
    top: 87.12%;
    left: 50%;
    transform: translateX(-50%);
    width: 53.5%;
    height: 8%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.medal-placeholder {
    width: 4vw;
    height: 90%;
    background-color: #ddd;
    border: 2px solid #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6vw;
    color: #666;
}

/* Footer Banner */
.footer-banner {
    position: absolute;
    bottom: 2.94%;
    left: 19.55%;
    width: 75.9%;
    height: 7.82%;
    background-color: #000;
    border: 3px solid #FFD700;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 5px 20px;
    box-shadow: inset 0 2px 4px rgba(255,215,0,0.3), inset 0 -2px 4px rgba(0,0,0,0.5);
}

.footer-line {
    font-family: 'UnifrakturMaguntia', cursive;
    color: #FFD700;
    text-align: center;
    line-height: 1.2;
}

.footer-line.large {
    font-size: 1.2vw;
    font-weight: bold;
}

.footer-line.medium {
    font-size: 0.9vw;
}

.footer-line.small {
    font-size: 0.8vw;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1400px) {
    .main-container {
        grid-template-columns: 45% 55%;
    }
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .preview-section {
        position: relative;
        top: 0;
        max-height: none;
    }

    .form-section {
        max-height: none;
    }

    .shadowbox-banner-text {
        font-size: 2.5vw;
    }

    .main-text-area {
        font-size: 1.3vw;
    }
}

@media (max-width: 768px) {
    .main-container {
        padding: 1rem;
    }

    .app-header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-left {
        flex-direction: column;
        gap: 1rem;
    }

    .button-group {
        flex-direction: column;
    }

    .shadowbox-banner-text {
        font-size: 3vw;
    }

    .main-text-area {
        font-size: 1.5vw;
    }
}
