/* ==========================================================================
   سامانه ثبت اطلاعات دانش‌آموزان و اولیا
   طراحی مدرن، واکنش‌گرا و راست‌چین (RTL)
   ========================================================================== */

:root {
    --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    
    /* Light Theme Palette */
    --bg-page: #f8fafc;
    --bg-gradient: radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
                   radial-gradient(circle at 85% 85%, rgba(16, 185, 129, 0.06) 0%, transparent 40%),
                   radial-gradient(circle at 50% 50%, #f1f5f9 0%, #f8fafc 100%);
    --card-bg: rgba(255, 255, 255, 0.85);
    --border-color: rgba(226, 232, 240, 0.9);
    --border-focus: #6366f1;
    
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: rgba(79, 70, 229, 0.1);
    --primary-glow: rgba(79, 70, 229, 0.25);
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.1);
    
    --text-heading: #0f172a;
    --text-main: #334155;
    --text-muted: #64748b;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    
    --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 40px -10px rgba(15, 23, 42, 0.12);
}

[data-theme="dark"] {
    --bg-page: #0b0f19;
    --bg-gradient: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
                   radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.12) 0%, transparent 40%),
                   #0b0f19;
    --card-bg: rgba(17, 24, 39, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #818cf8;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.2);
    --primary-glow: rgba(99, 102, 241, 0.4);
    
    --text-heading: #f8fafc;
    --text-main: #cbd5e1;
    --text-muted: #94a3b8;
    --input-bg: rgba(15, 23, 42, 0.7);
    --input-border: #334155;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    direction: rtl;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Navigation Header */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.logo-box {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), #06b6d4);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.nav-brand h1 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-heading);
    margin: 0;
}

.nav-brand p {
    font-size: 0.775rem;
    color: var(--text-muted);
    margin: 0;
}

.nav-tools {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
:root:not([data-theme="dark"]) .sun-icon { display: none; }
:root:not([data-theme="dark"]) .moon-icon { display: block; }

/* Main Container */
.main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
}

.form-wrapper {
    width: 100%;
    max-width: 680px;
}

.form-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2.25rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    animation: fadeInSlide 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.form-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #6366f1, #06b6d4, #10b981);
}

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

.card-header {
    text-align: center;
    margin-bottom: 2rem;
}

.card-header .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 9999px;
    font-size: 0.825rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.card-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.card-header p {
    font-size: 0.925rem;
    color: var(--text-muted);
}

/* Form Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem 1rem;
}

.col-span-2 {
    grid-column: span 2;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
}

.form-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-heading);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.label-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    font-size: 0.775rem;
    font-weight: 800;
}

.field-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: -0.1rem;
    margin-bottom: 0.25rem;
}

.easy-guide-box {
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
    padding: 1rem 1.15rem;
    margin-bottom: 1.75rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    text-align: right;
}

[data-theme="dark"] .easy-guide-box {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.3);
}

.guide-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guide-text strong {
    display: block;
    font-size: 0.925rem;
    color: var(--text-heading);
    margin-bottom: 0.2rem;
}

.guide-text p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.form-label .req {
    color: var(--error);
    margin-right: 0.2rem;
}

.form-label .counter {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
}

/* Input Fields */
.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    right: 1rem;
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.form-input,
.form-textarea {
    width: 100%;
    min-height: 52px;
    padding: 0.85rem 3rem 0.85rem 1rem;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-heading);
    font-family: inherit;
    font-size: 1.05rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-input.number-field {
    letter-spacing: 0.08em;
    font-weight: 600;
    font-size: 1.15rem;
}

.form-textarea {
    padding-right: 2.75rem;
    min-height: 90px;
    resize: vertical;
}

.input-wrap .textarea-icon {
    top: 1rem;
    align-items: flex-start;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.form-input:focus + .input-icon,
.input-wrap:focus-within .input-icon {
    color: var(--primary);
}

/* Validation Status */
.input-status {
    position: absolute;
    left: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.status-icon {
    display: none;
    width: 18px;
    height: 18px;
}

.form-group.is-valid .form-input,
.form-group.is-valid .form-textarea {
    border-color: var(--success);
}
.form-group.is-valid .icon-valid {
    display: block;
    color: var(--success);
}

.form-group.is-invalid .form-input,
.form-group.is-invalid .form-textarea {
    border-color: var(--error);
    box-shadow: 0 0 0 3px var(--error-light);
}
.form-group.is-invalid .icon-invalid {
    display: block;
    color: var(--error);
}

.error-message {
    font-size: 0.775rem;
    color: var(--error);
    display: none;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.2rem;
}

.form-group.is-invalid .error-message {
    display: flex;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    color: #ffffff;
    box-shadow: 0 4px 15px var(--primary-glow);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-submit {
    width: 100%;
    padding: 0.9rem 1.5rem;
    font-size: 1.05rem;
    margin-top: 1rem;
}

.btn-submit.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-submit .spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-submit.loading .spinner {
    display: block;
}
.btn-submit.loading .btn-text {
    display: none;
}

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

/* Success Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 100;
    animation: modalFade 0.3s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes modalFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.25rem 2rem;
    max-width: 520px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--success-light);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.modal-card h3 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}

.modal-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.tracking-box {
    background: var(--input-bg);
    border: 1px dashed var(--primary);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tracking-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tracking-val {
    font-family: monospace;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary);
    direction: ltr;
}

.btn-copy {
    background: var(--primary-light);
    border: none;
    color: var(--primary);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: background 0.2s;
}

.btn-copy:hover {
    background: var(--primary);
    color: white;
}

.modal-summary {
    background: rgba(99, 102, 241, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: right;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.modal-summary div {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    border-bottom: 1px dashed var(--border-color);
}
.modal-summary div:last-child {
    border-bottom: none;
}
.modal-summary span:first-child {
    color: var(--text-muted);
}
.modal-summary span:last-child {
    font-weight: 600;
    color: var(--text-heading);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
}

.modal-actions .btn {
    flex: 1;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-heading);
    font-size: 0.9rem;
    font-weight: 500;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    min-width: 280px;
}

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

.toast.toast-error {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.05);
}
.toast.toast-success {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

/* Responsive for Mobile Devices */
@media (max-width: 640px) {
    body {
        font-size: 16px;
    }
    .main-content {
        padding: 1rem 0.65rem 2rem;
    }
    .form-card {
        padding: 1.5rem 1.1rem;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-md);
    }
    .card-header h2 {
        font-size: 1.35rem;
    }
    .card-header p {
        font-size: 0.875rem;
    }
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    .col-span-2 {
        grid-column: span 1;
    }
    .form-label {
        font-size: 1rem;
        margin-bottom: 0.2rem;
    }
    .field-hint {
        font-size: 0.85rem;
        line-height: 1.4;
    }
    .form-input,
    .form-textarea {
        min-height: 54px;
        font-size: 1.1rem;
        padding: 0.85rem 3.1rem 0.85rem 1rem;
    }
    .form-input.number-field {
        font-size: 1.25rem;
        letter-spacing: 0.08em;
    }
    .btn-submit {
        min-height: 56px;
        font-size: 1.15rem;
        border-radius: var(--radius-md);
    }
    .navbar {
        padding: 0.75rem 0.85rem;
    }
    .nav-brand h1 {
        font-size: 1rem;
    }
    .nav-brand p {
        display: none;
    }
    .toast-container {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 1rem;
    }
    .modal-card {
        padding: 1.75rem 1.25rem;
        max-width: 95%;
    }
    .modal-card h3 {
        font-size: 1.25rem;
    }
    .tracking-val {
        font-size: 1.2rem;
    }
    .modal-actions {
        flex-direction: column;
    }
}

