/* ================================================================
   FGS Application System V2 — Modern Public Form Design System
   Faculty of Graduate Studies, University of Ruhuna
   ================================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- CSS Variables ---- */
:root {
    --primary: #0f2b5b;
    --primary-600: #1a3f7a;
    --primary-500: #2558a5;
    --primary-400: #3b7dda;
    --primary-100: #dbeafe;
    --primary-50: #eff6ff;

    --gold: #d4a017;
    --gold-light: #f6e27a;
    --gold-50: #fefce8;

    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fef2f2;

    --text-900: #0f172a;
    --text-700: #334155;
    --text-500: #64748b;
    --text-400: #94a3b8;
    --text-300: #cbd5e1;

    --bg: #f1f5f9;
    --white: #ffffff;
    --border: #e2e8f0;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-700);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ================================================================
   HERO HEADER
   ================================================================ */
.hero {
    background: linear-gradient(165deg, #06142e 0%, var(--primary) 40%, var(--primary-600) 70%, var(--primary-500) 100%);
    color: white;
    padding: 48px 24px 80px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(212, 160, 23, 0.08) 0%, transparent 70%);
    top: -200px;
    right: -100px;
    border-radius: 50%;
}

.hero::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(59, 125, 218, 0.1) 0%, transparent 70%);
    bottom: -150px;
    left: -100px;
    border-radius: 50%;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 640px;
    margin: 0 auto;
}

.hero-logo {
    height: 60px;
    margin-bottom: 24px;
    opacity: 0.95;
}

.hero h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
    line-height: 1.3;
}

.hero .subtitle {
    font-size: 0.95rem;
    font-weight: 400;
    opacity: 0.7;
    margin-bottom: 0;
}

.hero .admin-link {
    position: absolute;
    top: 20px;
    right: 24px;
    z-index: 2;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 6px 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.hero .admin-link:hover {
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.08);
}

/* ================================================================
   FORM SHELL
   ================================================================ */
.form-shell {
    max-width: 780px;
    margin: -48px auto 48px;
    padding: 0 16px;
    position: relative;
    z-index: 2;
}

/* ================================================================
   STEP PROGRESS BAR
   ================================================================ */
.progress-bar-wrapper {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 20px 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 24px;
    right: 24px;
    height: 3px;
    background: var(--text-300);
    border-radius: 4px;
    z-index: 0;
}

.progress-steps .track-fill {
    position: absolute;
    top: 16px;
    left: 24px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-400));
    border-radius: 4px;
    z-index: 1;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

.step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 2;
    cursor: pointer;
}

.step-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--white);
    border: 3px solid var(--text-300);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-400);
    transition: var(--transition);
}

.step-indicator.active .step-circle {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-50);
    box-shadow: 0 0 0 4px rgba(15, 43, 91, 0.1);
}

.step-indicator.completed .step-circle {
    border-color: var(--success);
    background: var(--success);
    color: white;
}

.step-indicator.completed .step-circle .step-num {
    display: none;
}

.step-indicator.completed .step-circle .step-check {
    display: block;
}

.step-circle .step-check {
    display: none;
    font-size: 0.75rem;
}

.step-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-400);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    transition: var(--transition);
}

.step-indicator.active .step-label {
    color: var(--primary);
}

.step-indicator.completed .step-label {
    color: var(--success);
}

/* Mobile progress */
@media (max-width: 640px) {
    .step-label {
        display: none;
    }

    .progress-bar-wrapper {
        padding: 16px 20px;
    }

    .step-circle {
        width: 30px;
        height: 30px;
        font-size: 0.72rem;
    }
}

/* ================================================================
   STEP PANELS
   ================================================================ */
.step-panel {
    display: none;
    animation: fadeSlideIn 0.4s ease forwards;
}

.step-panel.active {
    display: block;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 32px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.card-icon.blue {
    background: var(--primary-100);
    color: var(--primary);
}

.card-icon.gold {
    background: var(--gold-50);
    color: var(--gold);
}

.card-icon.green {
    background: var(--success-light);
    color: var(--success);
}

.card-icon.red {
    background: var(--danger-light);
    color: var(--danger);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-900);
    margin: 0;
}

.card-subtitle {
    font-size: 0.78rem;
    color: var(--text-500);
    margin: 0;
}

/* ================================================================
   FORM FIELDS
   ================================================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-700);
    margin-bottom: 6px;
}

.form-group label .req {
    color: var(--danger);
    margin-left: 2px;
}

.field {
    width: 100%;
    padding: 11px 14px;
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--text-900);
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: var(--transition);
}

.field:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 4px rgba(37, 88, 165, 0.08);
}

.field::placeholder {
    color: var(--text-400);
}

select.field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

textarea.field {
    resize: vertical;
    min-height: 100px;
}

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

@media (max-width: 640px) {

    .row-2,
    .row-3 {
        grid-template-columns: 1fr;
    }
}

/* ================================================================
   PROFILE PHOTO UPLOAD
   ================================================================ */
.photo-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.photo-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--border);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg);
}

.photo-preview:hover {
    border-color: var(--primary-400);
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview .overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 43, 91, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    color: white;
    font-size: 1.4rem;
}

.photo-preview:hover .overlay {
    opacity: 1;
}

.photo-label {
    font-size: 0.8rem;
    color: var(--text-500);
    font-weight: 500;
}

/* ================================================================
   FILE UPLOAD BOXES
   ================================================================ */
.file-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg);
    position: relative;
}

.file-drop:hover {
    border-color: var(--primary-400);
    background: var(--primary-50);
}

.file-drop.dragover {
    border-color: var(--primary-400);
    background: var(--primary-50);
}

.file-drop.has-file {
    border-color: var(--success);
    background: var(--success-light);
}

.file-drop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-drop .drop-icon {
    font-size: 1.6rem;
    color: var(--text-400);
    margin-bottom: 6px;
    transition: var(--transition);
}

.file-drop:hover .drop-icon {
    color: var(--primary-400);
}

.file-drop.has-file .drop-icon {
    color: var(--success);
}

.file-drop .drop-text {
    font-size: 0.82rem;
    color: var(--text-500);
    font-weight: 500;
}

.file-drop .drop-text .browse {
    color: var(--primary-500);
    font-weight: 600;
}

.file-drop .file-name-display {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--success);
    margin-top: 4px;
    display: none;
}

.file-drop.has-file .file-name-display {
    display: block;
}

.file-drop.has-file .drop-text {
    display: none;
}

.file-drop .file-hint {
    font-size: 0.72rem;
    color: var(--text-400);
    margin-top: 4px;
}

/* ================================================================
   RADIO / CHECKBOX
   ================================================================ */
.radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.radio-pill {
    position: relative;
}

.radio-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-pill label {
    display: inline-block;
    padding: 8px 18px;
    border: 2px solid var(--border);
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-500);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0 !important;
}

.radio-pill input[type="radio"]:checked+label {
    border-color: var(--primary);
    background: var(--primary-50);
    color: var(--primary);
}

.radio-pill label:hover {
    border-color: var(--primary-400);
}

.checkbox-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.checkbox-card:hover {
    border-color: var(--primary-400);
}

.checkbox-card input[type="checkbox"]:checked~.checkbox-card-label {
    color: var(--primary);
}

.checkbox-card input[type="checkbox"]:checked {
    accent-color: var(--primary);
}

/* ================================================================
   ENGLISH PROFICIENCY TABLE
   ================================================================ */
.proficiency-grid {
    display: grid;
    gap: 12px;
}

.proficiency-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}

.proficiency-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-700);
}

@media (max-width: 640px) {
    .proficiency-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ================================================================
   PAYMENT INFO BOX
   ================================================================ */
.info-box {
    background: linear-gradient(135deg, var(--primary-50), #f0f6ff);
    border: 1px solid rgba(37, 88, 165, 0.12);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.info-box h6 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.info-box p {
    font-size: 0.85rem;
    color: var(--text-700);
    margin-bottom: 0;
    line-height: 1.6;
}

.info-box .ref-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 2px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
}

.info-box .warning-note {
    color: var(--danger);
    font-weight: 600;
    font-size: 0.82rem;
    margin-top: 12px;
}

/* ================================================================
   DECLARATION
   ================================================================ */
.declaration-box {
    background: var(--gold-50);
    border: 1px solid rgba(212, 160, 23, 0.2);
    border-radius: var(--radius);
    padding: 18px 22px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.declaration-box input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.declaration-box label {
    font-size: 0.85rem;
    color: var(--text-700);
    cursor: pointer;
    margin-bottom: 0 !important;
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 12px 28px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-600));
    color: white;
    box-shadow: 0 4px 14px rgba(15, 43, 91, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(15, 43, 91, 0.35);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--white);
    color: var(--text-700);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--text-400);
    background: var(--bg);
}

.btn-submit {
    background: linear-gradient(135deg, var(--primary), var(--primary-500));
    color: white;
    font-size: 1rem;
    padding: 14px 40px;
    box-shadow: 0 4px 16px rgba(15, 43, 91, 0.3);
    width: 100%;
    justify-content: center;
}

.btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(15, 43, 91, 0.4);
}

.btn-submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ================================================================
   LOADER OVERLAY
   ================================================================ */
.loader-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(6, 20, 46, 0.75);
    backdrop-filter: blur(6px);
    z-index: 9999;
    flex-direction: column;
    gap: 20px;
}

.loader-overlay.active {
    display: flex;
}

.loader-spinner {
    width: 52px;
    height: 52px;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loader-text {
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ================================================================
   CKEditor Overrides
   ================================================================ */
.ck-editor__editable {
    min-height: 120px !important;
    font-family: var(--font) !important;
    border-radius: 0 0 var(--radius) var(--radius) !important;
}

.ck.ck-toolbar {
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

/* ================================================================
   FOOTER
   ================================================================ */
.form-footer {
    text-align: center;
    padding: 24px 16px 40px;
    color: var(--text-400);
    font-size: 0.78rem;
}

.form-footer a {
    color: var(--primary-400);
    text-decoration: none;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 640px) {
    .hero {
        padding: 36px 16px 64px;
    }

    .hero h1 {
        font-size: 1.3rem;
    }

    .form-shell {
        margin-top: -36px;
    }

    .card {
        padding: 20px;
        border-radius: var(--radius-lg);
    }

    .btn-row {
        flex-direction: column-reverse;
    }

    .btn-row .btn {
        width: 100%;
        justify-content: center;
    }

    .radio-group {
        gap: 6px;
    }

    .radio-pill label {
        padding: 6px 14px;
        font-size: 0.78rem;
    }
}