/* Native Mobile App Design for Nazareth School Calculator */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection for inputs */
input,
textarea {
    -webkit-user-select: text;
    -khtml-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    min-height: 100vh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* App Header */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    max-width: 420px;
    margin: 0 auto;
}

.back-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 8px;
    color: var(--primary-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn:hover {
    background: #f1f5f9;
}

.header-title {
    flex: 1;
    text-align: center;
    margin: 0 16px;
}

.header-title h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.header-title p {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-spacer {
    width: 36px;
}

/* App Navigation */
.app-nav {
    background: var(--surface);
    display: flex;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 61px;
    z-index: 99;
}

.nav-item {
    flex: 1;
    background: none;
    border: none;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-color);
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
}

.nav-item:active::before {
    opacity: 0.1;
    transform: scale(1);
}

.nav-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: #eff6ff;
}

.nav-icon {
    font-size: 20px;
    line-height: 1;
}

.nav-item span {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
}

/* Main Content */
.app-content {
    max-width: 420px;
    margin: 0 auto;
    min-height: calc(100vh - 122px);
    position: relative;
    padding-bottom: 80px;
}

.calc-screen {
    display: none;
    padding: 16px;
    animation: slideIn 0.3s ease-out;
}

.calc-screen.active {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.screen-header {
    text-align: center;
    margin-bottom: 24px;
}

.screen-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.screen-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Cards */
.form-card,
.subject-card,
.result-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.result-card {
    display: none;
}

.result-card.show {
    display: block;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Input Sections */
.input-section {
    margin-bottom: 16px;
}

.input-section:last-child {
    margin-bottom: 0;
}

.input-section label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--text-secondary);
    pointer-events: none;
}

select,
input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    background: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s ease;
    appearance: none;
}

select {
    padding-right: 40px;
    cursor: pointer;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input::placeholder {
    color: var(--text-secondary);
}

/* Buttons */
.primary-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.primary-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.primary-btn:active::before {
    width: 300px;
    height: 300px;
}

.primary-btn:hover {
    background: var(--primary-dark);
}

.primary-btn:active {
    transform: scale(0.98);
}

/* Subject Lists */
.subjects-list,
.students-list {
    margin-bottom: 16px;
}

.subject-card {
    position: relative;
    overflow: hidden;
}

.subject-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.subject-title::before {
    content: '📚';
    font-size: 18px;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.input-group {
    margin-bottom: 12px;
}

.input-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group input {
    padding: 12px 14px;
    font-size: 15px;
}

/* Converted Mark Display */
.converted-mark {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 2px solid var(--success-color);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
    position: relative;
}

.converted-mark-title {
    font-weight: 600;
    font-size: 12px;
    color: #065f46;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calculation-display {
    font-size: 14px;
    color: #047857;
    margin-bottom: 12px;
    font-family: 'SF Mono', Monaco, monospace;
}

.total-result {
    background: var(--success-color);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Result Cards */
.result-title {
    font-weight: 600;
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-align: center;
}

.total-marks {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3);
}

.subject-breakdown {
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-left: 4px solid var(--primary-color);
}

.subject-breakdown-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.subject-breakdown-marks {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'SF Mono', Monaco, monospace;
}

/* Student Inputs */
.student-input {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.student-input label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.student-input label::before {
    content: '👤';
    font-size: 16px;
}

/* Rank Results */
.rank-list {
    margin-top: 16px;
}

.rank-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    margin-bottom: 8px;
    background: var(--surface);
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
}

.rank-item:hover {
    transform: translateY(-1px);
}

.rank-item:first-child {
    border-left-color: #fbbf24;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.rank-position {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.rank-item:first-child .rank-position {
    color: #d97706;
}

.rank-position::before {
    content: '🏅';
    font-size: 18px;
}

.rank-item:first-child .rank-position::before {
    content: '🥇';
}

.rank-marks {
    font-weight: 600;
    color: var(--success-color);
    font-size: 16px;
}

/* Floating Action Button */
.fab-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--danger-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(239, 68, 68, 0.4);
}

.fab:active {
    transform: scale(0.95);
}

/* Reset Section & Buttons */
.reset-section {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

.reset-btn {
    background-color: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    border-radius: 999px;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reset-btn:hover {
    background-color: #f1f5f9;
    color: var(--danger-color);
    border-color: #fecaca;
}

.reset-btn:active {
    transform: scale(0.98);
}


/* Responsive Design */
@media (min-width: 421px) {
    body {
        background: #f1f5f9;
        padding: 20px 0;
    }

    .app-header,
    .app-nav {
        position: static;
    }

    .app-content {
        background: var(--surface);
        border-radius: 20px;
        box-shadow: var(--shadow-lg);
        margin: 20px auto;
        overflow: hidden;
    }

    .calc-screen {
        padding: 24px;
    }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;
        --surface: #1e293b;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --border-color: #334155;
    }

    .nav-item.active {
        background: rgba(37, 99, 235, 0.1);
    }

    .converted-mark {
        background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
    }

    .subject-breakdown {
        background: #334155;
    }

    .rank-item:first-child {
        background: linear-gradient(135deg, #451a03 0%, #78350f 100%);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000;
        --border-color: #000;
    }

    input,
    select {
        border-width: 3px;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Na
tive Mobile App Enhancements */

/* Pull-to-refresh indicator */
.pull-to-refresh {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    transition: all 0.3s ease;
}

/* Swipe gestures */
.swipe-indicator {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1001;
}

/* Enhanced touch feedback */
.touch-feedback {
    position: relative;
    overflow: hidden;
}

.touch-feedback::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s, opacity 0.3s;
    opacity: 0;
    pointer-events: none;
}

.touch-feedback:active::after {
    width: 200px;
    height: 200px;
    opacity: 1;
}

/* Status bar safe area */
@supports (padding-top: env(safe-area-inset-top)) {
    .app-header {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
}

/* Home indicator safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .fab-container {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* Improved scrolling */
.app-content {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Native-like transitions */
.calc-screen {
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.calc-screen.active {
    transform: translateX(0);
}

.calc-screen.slide-out {
    transform: translateX(-100%);
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Improved form validation */
.input-error {
    border-color: var(--danger-color) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.input-success {
    border-color: var(--success-color) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--surface);
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1002;
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Haptic feedback simulation */
@keyframes haptic {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-1px);
    }

    75% {
        transform: translateX(1px);
    }
}

.haptic-feedback {
    animation: haptic 0.1s ease-in-out;
}

/* Better focus indicators for accessibility */
.focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Optimize for notched devices */
@media screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
    .app-header {
        padding-top: 44px;
    }
}

/* Landscape optimizations */
@media (orientation: landscape) and (max-height: 500px) {
    .app-header {
        padding: 8px 16px;
    }

    .header-title h1 {
        font-size: 16px;
    }

    .nav-item {
        padding: 8px 6px;
    }

    .nav-icon {
        font-size: 16px;
    }

    .nav-item span {
        font-size: 10px;
    }

    .calc-screen {
        padding: 12px 16px;
    }

    .form-card,
    .subject-card {
        padding: 16px;
        margin-bottom: 12px;
    }
}

/* Performance optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    .calc-screen,
    .nav-item,
    .primary-btn,
    .touch-feedback::after {
        transition: none !important;
        animation: none !important;
    }
}

/* I
nfo Card Styles */
.info-card {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.info-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.info-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.info-text {
    font-size: 14px;
    line-height: 1.4;
    color: #1e40af;
}

.info-text strong {
    color: #1e3a8a;
}

/* Dark mode for info card */
@media (prefers-color-scheme: dark) {
    .info-card {
        background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
        border-color: #3b82f6;
    }

    .info-text {
        color: #dbeafe;
    }

    .info-text strong {
        color: #ffffff;
    }
}

/* Re
set Button Styles */
.reset-section {
    margin-top: 24px;
    padding: 0 16px;
}

.reset-btn {
    width: 100%;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    position: relative;
    overflow: hidden;
}

.reset-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.reset-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.reset-btn:active {
    transform: translateY(0);
}

.reset-btn:active::before {
    width: 300px;
    height: 300px;
}

.reset-btn svg {
    flex-shrink: 0;
}

.reset-btn span {
    font-weight: 600;
}

/* Validation Error Messages */
.validation-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: shake 0.5s ease-in-out;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
}

.validation-message::before {
    content: '⚠️';
    font-size: 16px;
    flex-shrink: 0;
}

.validation-message.warning {
    background: #fffbeb;
    border-color: #fed7aa;
    color: #d97706;
}

.validation-message.warning::before {
    content: '💡';
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Enhanced Input Validation Styles */
.input-error {
    border-color: var(--danger-color) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
    animation: inputError 0.3s ease-in-out;
}

.input-success {
    border-color: var(--success-color) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

@keyframes inputError {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    75% {
        transform: translateX(3px);
    }
}

/* Dark mode for reset button and validation */
@media (prefers-color-scheme: dark) {
    .validation-message {
        background: #450a0a;
        border-color: #dc2626;
        color: #fca5a5;
    }

    .reset-btn {
        background: #dc2626;
    }

    .reset-btn:hover {
        background: #b91c1c;
    }
}

/* R
ank Calculator Class Selection */
.class-selection-rank {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.class-selection-rank label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

#rank-inputs-container {
    margin-top: 16px;
}