/**
 * SAP Application Form — Front-end Styles
 */

/* ──────────────── Design Tokens (site brand colors) ──────────────── */
.sap-application-form {
    --sap-primary: #046bd2;
    --sap-primary-dark: #045cb4;
    --sap-heading: #1e293b;
    --sap-text: #334155;
    --sap-white: #ffffff;
    --sap-bg-light: #f0f5fa;
    --sap-ink: #111111;
    --sap-border: #d1d5db;
    --sap-success: #10b981;
    --sap-success-dark: #059669;
    --sap-danger: #ef4444;

    --sap-radius-sm: 8px;
    --sap-radius: 14px;
    --sap-radius-lg: 22px;
    --sap-radius-full: 999px;

    --sap-max-width: 1440px;
}

/* ──────────────── Reset / Base ──────────────── */
.sap-application-form {
    max-width: var(--sap-max-width);
    width: 100%;
    box-sizing: border-box;
    margin: 40px auto;
    padding: 0 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--sap-text);
    line-height: 1.6;
}

.sap-application-form *,
.sap-application-form *::before,
.sap-application-form *::after {
    box-sizing: border-box;
}

.sap-form {
    max-width: 900px;
    margin: 0 auto;
    background: var(--sap-white);
    border: 1px solid var(--sap-border);
    border-radius: var(--sap-radius-lg);
    padding: 44px 48px;
    box-shadow: 0 1px 2px rgba(17, 17, 17, 0.04), 0 12px 32px -16px rgba(4, 107, 210, 0.12);
}

/* ──────────────── Progress Bar ──────────────── */
.sap-progress-bar {
    max-width: 900px;
    margin: 0 auto 32px;
    padding: 0 10px;
}

.sap-progress-bar__track {
    position: relative;
    height: 6px;
    background: var(--sap-bg-light);
    border-radius: var(--sap-radius-full);
    margin-bottom: 24px;
    overflow: hidden;
}

.sap-progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sap-primary), var(--sap-primary-dark));
    border-radius: var(--sap-radius-full);
    transition: width 0.5s ease;
    width: 0%;
}

.sap-progress-bar__fill[data-step="1"] { width: 0%; }
.sap-progress-bar__fill[data-step="2"] { width: 50%; }
.sap-progress-bar__fill[data-step="3"] { width: 100%; }

.sap-progress-bar__steps {
    display: flex;
    justify-content: space-between;
    position: relative;
}

.sap-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    position: relative;
    z-index: 1;
}

.sap-progress-step__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--sap-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sap-bg-light);
    color: #94a3b8;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

/* ──────────────── SVG Icons ──────────────── */
.sap-svg-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.sap-progress-step__icon .sap-svg-icon {
    width: 22px;
    height: 22px;
}

.sap-drop-zone__icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: var(--sap-radius);
    background: var(--sap-bg-light);
    color: var(--sap-primary);
    margin-bottom: 12px;
    transition: background 0.2s ease, transform 0.2s ease;
}

.sap-drop-zone__icon-badge .sap-svg-icon {
    width: 26px;
    height: 26px;
}

.sap-drop-zone:hover .sap-drop-zone__icon-badge,
.sap-drop-zone.drag-over .sap-drop-zone__icon-badge {
    background: var(--sap-primary);
    color: var(--sap-white);
    transform: translateY(-2px);
}

.sap-btn__icon {
    width: 16px;
    height: 16px;
}

.sap-success-icon .sap-svg-icon {
    width: 40px;
    height: 40px;
}

.sap-file-icon .sap-svg-icon {
    width: 22px;
    height: 22px;
}

.sap-progress-step.active .sap-progress-step__icon,
.sap-progress-step.completed .sap-progress-step__icon {
    background: var(--sap-primary);
    color: var(--sap-white);
    border-color: var(--sap-primary);
}

.sap-progress-step.completed .sap-progress-step__icon {
    background: var(--sap-success);
    border-color: var(--sap-success);
}

.sap-progress-step__label {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

.sap-progress-step.active .sap-progress-step__label,
.sap-progress-step.completed .sap-progress-step__label {
    color: var(--sap-heading);
}

/* ──────────────── Form Steps ──────────────── */
.sap-form-step {
    display: none;
    animation: sapFadeIn 0.4s ease;
}

.sap-form-step.active {
    display: block;
}

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

.sap-form-step__title {
    font-size: 26px;
    font-weight: 700;
    color: var(--sap-ink);
    margin: 0 0 6px;
}

.sap-form-step__subtitle {
    font-size: 15px;
    color: var(--sap-text);
    margin: 0 0 30px;
}

/* ──────────────── Form Groups ──────────────── */
.sap-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.sap-form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.sap-form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--sap-text);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sap-required {
    color: var(--sap-danger);
}

/* ──────────────── Inputs ──────────────── */
.sap-input,
.sap-textarea,
.sap-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--sap-border);
    border-radius: var(--sap-radius);
    font-size: 15px;
    font-family: inherit;
    color: var(--sap-heading);
    background: var(--sap-white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.sap-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 0px 16px;
    padding-right: 48px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23334155' d='M12 0L6 6 0 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.sap-input:focus,
.sap-textarea:focus,
.sap-select:focus {
    border-color: var(--sap-primary);
    box-shadow: 0 0 0 4px rgba(4, 107, 210, 0.14);
}

.sap-input.error,
.sap-textarea.error,
.sap-select.error {
    border-color: var(--sap-danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.sap-textarea {
    resize: vertical;
    min-height: 80px;
}

.sap-select option {
    padding: 4px 8px;
    font-size: 15px;
}

/* ──────────────── Upload Zones ──────────────── */
.sap-upload-group {
    margin-bottom: 24px;
}

.sap-upload-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--sap-text);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sap-file-count {
    font-weight: 400;
    color: var(--sap-primary);
    text-transform: none;
    font-size: 12px;
}

.sap-drop-zone {
    border: 2px dashed var(--sap-border);
    border-radius: var(--sap-radius-lg);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--sap-bg-light);
    position: relative;
}

.sap-drop-zone--large {
    padding: 46px 20px;
}

.sap-drop-zone:hover,
.sap-drop-zone.drag-over {
    border-color: var(--sap-primary);
    background: #e7f1fc;
}

.sap-drop-zone.drag-over {
    transform: scale(1.01);
}

.sap-drop-zone__content p {
    margin: 0;
    font-size: 14px;
    color: var(--sap-text);
}

.sap-drop-zone__hint {
    font-size: 12px !important;
    color: #64748b !important;
    margin-top: 4px !important;
}

.sap-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ──────────────── File Previews ──────────────── */
.sap-file-preview {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.sap-file-preview--grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}

.sap-file-item {
    position: relative;
    border-radius: var(--sap-radius);
    overflow: hidden;
    border: 2px solid var(--sap-border);
    background: var(--sap-white);
    transition: border-color 0.2s ease;
    animation: sapFileIn 0.3s ease;
}

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

.sap-file-item:hover {
    border-color: var(--sap-primary);
}

.sap-file-item--image {
    width: 100px;
    height: 100px;
}

.sap-file-item--image .sap-file-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sap-file-item--video {
    width: 120px;
    height: 100px;
    display: flex;
    flex-direction: column;
    background: var(--sap-heading);
}

.sap-file-item--video .sap-file-thumb {
    width: 100%;
    height: 70px;
    object-fit: cover;
}

.sap-file-item--video .sap-file-video-badge {
    padding: 4px 8px;
    font-size: 10px;
    color: var(--sap-white);
    text-align: center;
    background: rgba(0,0,0,0.5);
}

.sap-file-item--file {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 140px;
}

.sap-file-item--file .sap-file-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--sap-primary);
}

.sap-file-item--file .sap-file-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--sap-text);
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sap-file-item--file .sap-file-size {
    font-size: 10px;
    color: #94a3b8;
    margin-left: auto;
    flex-shrink: 0;
}

.sap-file-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: var(--sap-radius-full);
    background: rgba(239, 68, 68, 0.9);
    color: var(--sap-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 0;
}

.sap-file-item:hover .sap-file-remove {
    opacity: 1;
}

.sap-file-progress {
    height: 3px;
    background: var(--sap-bg-light);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.sap-file-progress-bar {
    height: 100%;
    background: var(--sap-primary);
    transition: width 0.2s ease;
}

/* ──────────────── Buttons ──────────────── */
.sap-form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 30px;
    gap: 12px;
}

.sap-form-actions--between {
    justify-content: space-between;
}

.sap-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--sap-radius);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1;
}

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

.sap-btn--primary:hover {
    background: var(--sap-primary-dark);
    border-color: var(--sap-primary-dark);
    box-shadow: 0 4px 12px rgba(4, 107, 210, 0.3);
}

.sap-btn--outline {
    background: transparent;
    color: var(--sap-primary);
    border-color: var(--sap-border);
}

.sap-btn--outline:hover {
    background: var(--sap-bg-light);
    border-color: var(--sap-primary);
}

.sap-btn--submit {
    background: linear-gradient(135deg, var(--sap-success), var(--sap-success-dark));
    color: var(--sap-white);
    border-color: var(--sap-success-dark);
    padding: 16px 36px;
    font-size: 16px;
}

.sap-btn--submit:hover {
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.sap-btn--submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.sap-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--sap-white);
    border-radius: var(--sap-radius-full);
    animation: sapSpin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes sapSpin {
    to { transform: rotate(360deg); }
}

/* ──────────────── Success Screen ──────────────── */
.sap-success-content {
    text-align: center;
    padding: 40px 20px;
}

.sap-success-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--sap-radius-full);
    background: var(--sap-success);
    color: var(--sap-white);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    animation: sapBounceIn 0.5s ease;
}

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

.sap-success-content h2 {
    font-size: 24px;
    color: var(--sap-ink);
    margin: 0 0 12px;
}

.sap-success-content p {
    font-size: 15px;
    color: var(--sap-text);
    max-width: 400px;
    margin: 0 auto 12px;
}

.sap-success-ref {
    font-size: 16px !important;
    color: var(--sap-heading) !important;
    background: var(--sap-bg-light);
    display: inline-block;
    padding: 10px 24px;
    border-radius: var(--sap-radius);
    margin-bottom: 24px !important;
}

/* ──────────────── Message Overlay ──────────────── */
.sap-form-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: var(--sap-radius);
    font-size: 14px;
    font-weight: 500;
    z-index: 999999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    animation: sapSlideIn 0.3s ease;
    max-width: 400px;
}

.sap-form-message--success {
    background: var(--sap-success);
    color: var(--sap-white);
}

.sap-form-message--error {
    background: var(--sap-danger);
    color: var(--sap-white);
}

@keyframes sapSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ──────────────── Validation ──────────────── */
.sap-validation-error {
    font-size: 12px;
    color: var(--sap-danger);
    margin-top: 4px;
    display: none;
}

.sap-form-group.has-error .sap-validation-error {
    display: block;
}

/* ──────────────── Admin Panel ──────────────── */
.sap-admin-wrap {
    padding: 0;
}

.sap-admin-filters {
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sap-detail-panel {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    padding: 30px;
    margin-top: 24px;
}

.sap-detail-section {
    margin-bottom: 24px;
}

.sap-detail-section h3 {
    font-size: 16px;
    color: #1e293b;
    border-bottom: 2px solid #046bd2;
    padding-bottom: 8px;
    margin: 0 0 16px;
}

.sap-detail-section h4 {
    font-size: 14px;
    color: #475569;
}

.sap-detail-table {
    width: 100%;
    border-collapse: collapse;
}

.sap-detail-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.sap-detail-table td:first-child {
    width: 200px;
    color: #64748b;
    font-size: 13px;
}

.sap-detail-table td:nth-child(2) {
    color: #1e293b;
    font-size: 14px;
}

/* ──────────────── File List (Admin) ──────────────── */
.sap-file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sap-file-list li {
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.sap-file-list li:last-child {
    border-bottom: none;
}

.sap-file-download {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #046bd2;
    font-size: 13px;
    transition: color 0.2s ease;
}

.sap-file-download:hover {
    color: #045cb4;
}

.sap-file-icon {
    font-size: 18px;
}

.sap-file-name {
    flex: 1;
    font-weight: 500;
}

.sap-file-size {
    color: #94a3b8;
    flex-shrink: 0;
}

/* ──────────────── Empty State ──────────────── */
.sap-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
    font-size: 16px;
}

/* ──────────────── Responsive ──────────────── */
@media (max-width: 960px) {
    .sap-form {
        padding: 32px 24px;
    }
}

@media (max-width: 640px) {
    .sap-application-form {
        margin: 20px auto;
        padding: 0 16px;
    }

    .sap-form {
        padding: 24px 18px;
        border-radius: var(--sap-radius);
    }

    .sap-form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .sap-form-step__title {
        font-size: 22px;
    }

    .sap-progress-step__label {
        font-size: 10px;
    }

    .sap-progress-step__icon {
        width: 38px;
        height: 38px;
    }

    .sap-progress-step__icon .sap-svg-icon {
        width: 18px;
        height: 18px;
    }

    .sap-form-actions {
        flex-direction: column;
    }

    .sap-form-actions--between {
        flex-direction: column;
    }

    .sap-btn {
        width: 100%;
        justify-content: center;
    }

    .sap-file-preview--grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .sap-drop-zone--large {
        padding: 30px 16px;
    }

    .sap-admin-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .sap-detail-table td:first-child {
        width: auto;
        display: block;
        padding-bottom: 2px;
        font-size: 11px;
        text-transform: uppercase;
    }

    .sap-detail-table td:nth-child(2) {
        display: block;
        padding-top: 0;
        padding-bottom: 12px;
    }
}
