* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: white; min-height: 100vh; }
.container { max-width: 800px; margin: 0 auto; background: white; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); overflow: hidden; }
.header { background: #000000; color: white; padding: 20px 30px; text-align: center;border-bottom: 1px solid black }
.header-logo { display: flex; align-items: center; justify-content: center; margin-bottom: 15px; }
.header-logo img { height: 50px; margin-right: 15px; }
.form-container { padding: 40px; }
.form-group { margin-bottom: 25px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #333; }
.file-upload-area { border: 2px dashed #ddd; border-radius: 8px; padding: 40px; text-align: center; background: #fafafa; transition: all 0.3s ease; cursor: pointer; position: relative; }
.file-upload-area:hover { border-color: #e8a321; background: #fffbf0; }
.file-upload-area input[type="file"] { position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; cursor: pointer; }

/* Mobile-specific improvements */
@media (max-width: 768px) {
    .container { margin: 0; box-shadow: none; }
    .form-container { padding: 20px; }
    .file-upload-area { padding: 30px 20px; }
    .upload-icon { font-size: 2.5rem; }
    .submit-btn { padding: 18px 20px; font-size: 1rem; }
    .step-nav { padding: 15px; }
    .step { margin: 0 5px; min-width: 100px; }
    .step-text { font-size: 0.8rem; }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .file-upload-area { min-height: 120px; }
    .submit-btn { min-height: 48px; }
    .remove-btn { min-height: 36px; min-width: 60px; }
}
.upload-icon { font-size: 3rem; color: #e8a321; margin-bottom: 15px; }
.submit-btn { background: #e8a321; color: white; border: none; padding: 15px 30px; border-radius: 8px; font-size: 1.1rem; font-weight: 600; cursor: pointer; width: 100%; transition: all 0.3s ease; margin-top: 20px; }
.submit-btn:hover { background: #d1941e; }
            .submit-btn:disabled { background: #ccc; cursor: not-allowed; }
    .loading { display: none; text-align: center; padding: 20px; margin-bottom: 20px; }
    .processing-overlay { 
        display: none; 
        position: fixed; 
        top: 0; 
        left: 0; 
        width: 100%; 
        height: 100%; 
        background: rgba(0, 0, 0, 0.7); 
        z-index: 1000; 
        backdrop-filter: blur(2px);
    }
    .processing-modal {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: white;
        padding: 40px;
        border-radius: 12px;
        text-align: center;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        min-width: 300px;
    }
.spinner { border: 4px solid #f3f3f3; border-top: 4px solid #e8a321; border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 0 auto 15px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.result { margin-top: 20px; padding: 20px; border-radius: 8px; display: none; }
.result.success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }
.result.error { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; }

/* Step navigation */
.step-nav { 
    display: flex; 
    justify-content: center; 
    margin-bottom: 30px; 
    background: #f8f9fa; 
    padding: 20px; 
    border-radius: 8px; 
    flex-wrap: wrap;
    gap: 10px;
}
.step { 
    display: flex; 
    align-items: center; 
    margin: 0 10px; 
    min-width: 120px;
    flex: 1;
    max-width: 200px;
}
.step-number { 
    width: 35px; 
    height: 35px; 
    border-radius: 50%; 
    background: #ddd; 
    color: #666; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-weight: bold; 
    margin-right: 10px; 
    flex-shrink: 0;
}
.step.active .step-number { background: #e8a321; color: white; }
.step.completed .step-number { background: #28a745; color: white; }
.step-text {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Step containers */
.step-container { display: none; }
.step-container.active { display: block; }

/* Edit form */
.edit-form { background: #f8f9fa; padding: 20px; border-radius: 8px; margin: 20px 0; }
.form-row { display: flex; gap: 15px; margin-bottom: 15px; }
.form-col { flex: 1; }
.form-col input { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 1rem; }
.form-col label { display: block; margin-bottom: 5px; font-weight: 600; color: #333; }

/* Action buttons */
.action-buttons { display: flex; justify-content: space-between; margin-top: 20px; }
.btn { padding: 12px 24px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; transition: all 0.3s ease; }
.btn-primary { background: #e8a321; color: white; }
.btn-primary:hover { background: #d1941e; }
.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #5a6268; }
.btn-success { background: #28a745; color: white; }
.btn-success:hover { background: #218838; }

/* Letter preview */
.letter-preview { background: white; border: 1px solid #ddd; border-radius: 8px; padding: 30px; margin: 20px 0; }

/* Mobile letter preview - no box, left-justified text */
@media (max-width: 768px) {
    .letter-preview { 
        background: transparent; 
        border: none; 
        border-radius: 0; 
        padding: 0; 
        margin: 10px 0; 
        text-align: left;
    }
    
    /* Mobile button layout for Step 3 */
    .letter-preview button {
        font-size: 12px !important;
        padding: 6px 12px !important;
        min-width: 80px;
    }
    
    .letter-preview div[style*="display: flex"] {
        gap: 8px !important;
    }
    

    
    /* Mobile signature buttons in letter preview */
    .signature-buttons button {
        font-size: 12px !important;
        padding: 6px 10px !important;
        min-width: 80px !important;
    }
    
    .signature-buttons {
        gap: 8px !important;
    }
    
    /* Mobile solar spot layout for Step 4 */
    #step4-container div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 20px !important;
    }
    
    #step4-container .solar-spot-diagram {
        order: 1 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        min-height: 250px !important;
        width: 100% !important;
    }
    
    #step4-container .solar-spot-diagram svg {
        max-width: 100% !important;
        height: auto !important;
    }
    
    #step4-container .solar-legend {
        order: 2 !important;
        height: auto !important;
        min-height: 120px !important;
        padding: 15px !important;
        width: 100% !important;
    }
    
    #step4-container .solar-legend > div {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        gap: 8px !important; /* replaces margin-right on icon */
        width: 100% !important;
        margin: 4px 0 !important;
    }
    
    #step4-container .solar-legend .legend-color {
        flex: 0 0 20px !important; 
        height: 20px !important;
    }
    
    #step4-container .solar-legend span:not(.legend-color) {
        display: inline-block !important;  /* <- KEY change */
        white-space: normal !important;    /* allow wrapping */
        flex: 1 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    .legend-text {
        display: inline-block;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    #step4-container .results-explanation {
        order: 3 !important;
    }
    
    /* Mobile solar input fields */
    #step4-container .solar-input-row {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    #step4-container .solar-input-row > div {
        flex: none !important;
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
    }
    
    #step4-container .solar-input-row label {
        display: inline-block !important;
        margin-bottom: 0 !important;
        min-width: 140px !important;
        font-size: 0.9rem !important;
    }
    
    #step4-container .solar-input-row input {
        flex: 1 !important;
        width: auto !important;
        min-width: 80px !important;
        text-align: right !important;
    }
    
    /* Mobile authority form text optimization */
    #step3-container h2 {
        font-size: 1.5rem;
        margin-bottom: 10px;
        text-align: left;
    }
    
    #step3-container p {
        font-size: 0.95rem;
        line-height: 1.4;
        margin-bottom: 15px;
        text-align: left;
    }
    
    /* Ensure letter content matches introductory text width */
    .letter-preview * {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Override letter template styles for mobile preview */
    .letter-preview .letter-container {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .letter-preview .letter-header {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .letter-preview .letter-recipient,
    .letter-preview .letter-logo {
        flex: none !important;
        width: 100% !important;
    }
    
    .letter-preview .letter-logo {
        text-align: left !important;
    }
    
    .letter-preview .customer-details {
        width: 100% !important;
        margin: 15px 0 !important;
    }
    
    .letter-preview .letter-body {
        width: 100% !important;
        text-align: left !important;
    }
    
    .letter-preview .letter-signature {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .letter-preview .signature-right {
        text-align: left !important;
        align-items: flex-start !important;
    }
}
.signature-box { 
    width: 100%; 
    height: 100px; 
    border: 2px solid #e8a321; 
    border-radius: 8px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: #fff8e6; 
    cursor: pointer; 
    transition: all 0.3s ease; 
}
.signature-box:hover { background: #ffe8b3; }
.signature-box.signed { background: #d4edda; border-color: #28a745; }

            /* Missing fields warning */
    .missing-fields { background: #fff3cd; border: 1px solid #ffeaa7; color: #856404; padding: 15px; border-radius: 6px; margin: 20px 0; }
    .missing-fields h3 { margin-bottom: 10px; color: #856404; }
    .missing-fields ul { margin-left: 20px; }
    .missing-fields li { margin-bottom: 5px; }
    
    /* Missing field highlighting */
    input[style*="border-color: #ff4444"] { 
        border-color: #ff4444 !important; 
        border-width: 2px !important; 
        background-color: #fff5f5 !important;
        box-shadow: 0 0 5px rgba(255, 68, 68, 0.3) !important;
    }
    
    /* File list styles */
    .file-list { margin-top: 20px; }
    .file-list h4 { margin-bottom: 10px; color: #333; }
    .file-items { display: flex; flex-direction: column; gap: 10px; }
    .file-item { 
        display: flex; 
        align-items: center; 
        justify-content: space-between; 
        padding: 10px; 
        background: #f8f9fa; 
        border: 1px solid #ddd; 
        border-radius: 6px; 
        font-size: 0.9rem; 
    }
    .file-item .file-info { display: flex; align-items: center; gap: 10px; }
    .file-item .file-icon { font-size: 1.2rem; }
    .file-item .file-name { font-weight: 500; color: #333; }
    .file-item .file-size { color: #666; font-size: 0.8rem; }
    .file-item .remove-btn { 
        background: #dc3545; 
        color: white; 
        border: none; 
        padding: 5px 10px; 
        border-radius: 4px; 
        cursor: pointer; 
        font-size: 0.8rem; 
        transition: background 0.3s ease; 
    }
    .file-item .remove-btn:hover { background: #c82333; }

@media (max-width: 768px) {
    .container { margin: 0; box-shadow: none; }
    .form-container { padding: 20px; }
    .form-row { flex-direction: column; }
    .action-buttons { flex-direction: column; }
    
    /* Mobile step navigation */
    .step-nav {
        padding: 15px;
        gap: 5px;
    }
    .step {
        margin: 0 5px;
        min-width: 100px;
        max-width: 150px;
    }
    .step-number {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    .step-text {
        font-size: 0.8rem;
    }
    
    /* Mobile button layout for signature step */
    .signature-buttons {
        display: flex;
        justify-content: flex-start;
        gap: 10px;
        margin-top: 10px;
    }
    
    .signature-buttons button {
        padding: 10px 12px;
        font-size: 13px;
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .step-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding-left: 20px;
    }
    .step {
        width: 100%;
        max-width: 250px;
        justify-content: flex-start;
        align-items: center;
        position: relative;
    }
    .step-number {
        margin-right: 15px;
        flex-shrink: 0;
    }
    .step-text {
        text-align: left;
        flex: 1;
    }
    /* Align all steps to the left with some right padding */
    .step:nth-child(1),
    .step:nth-child(2),
    .step:nth-child(3) {
        justify-content: flex-start;
        padding-right: 20px;
    }
    

    
    .btn {
        padding: 10px 15px !important;
        font-size: 0.9rem !important;
    }

    /* Mobile camera-only styling */
    .file-upload-area {
        background: #e8f5e8 !important;
        border-color: #4CAF50 !important;
    }

    .file-upload-area .upload-icon {
        font-size: 2.5rem;
        color: #4CAF50;
    }

    .file-upload-area .upload-text {
        color: #2E7D32;
        font-weight: 600;
    }

    .file-upload-area .upload-hint {
        color: #388E3C;
        font-size: 0.85rem;
    }
}