/* RIT App Design (Based on Nazareth Calculator) */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --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);

    /* Safe Area Variables */
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

input,
textarea {
    -webkit-user-select: text;
    user-select: text;
}

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;
    min-height: 100vh;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-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: 600px;
    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;
}

/* Main Content */
.app-content {
    max-width: 600px;
    margin: 0 auto;
    min-height: calc(100vh - 60px);
    padding: 16px;
}

/* Cards */
.card,
.form-card,
.result-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

/* Inputs */
.input-section {
    margin-bottom: 16px;
}

.input-section label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

input[type="number"],
input[type="text"],
select {
    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;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Buttons */
.btn,
.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;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    text-decoration: none;
}

.btn:hover,
.primary-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    box-shadow: none;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Info Card / Alert */
.info-card,
.alert {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #1e40af;
    line-height: 1.4;
}

.info-card strong,
.alert strong {
    color: #1e3a8a;
}

/* Subject Validation Styles */
.input-group {
    margin-bottom: 12px;
}

.subject-selection {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.marks-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 24px 0;
}

.results-section {
    margin-top: 16px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.results-section ul {
    list-style: none;
    padding: 0;
    margin: 12px 0;
    font-size: 14px;
}

.results-section li {
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color);
}

.results-section li:last-child {
    border-bottom: none;
}

.status-box {
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    margin-top: 12px;
}

.status-pass {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status-fail {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.status-pending {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde047;
}

.suggestion-text {
    font-weight: 400;
    font-size: 13px;
    margin-top: 6px;
    color: var(--text-primary);
}

@media (min-width: 480px) {
    .marks-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .subject-selection {
        grid-template-columns: 1fr 1fr;
    }
}

.subject-card {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Results Table */
.table-container {
    overflow-x: auto;
    margin-bottom: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Responsive adjustment */
@media (min-width: 600px) {
    .app-content {
        margin: 20px auto;
        border-radius: 20px;
        box-shadow: var(--shadow-lg);
        background: var(--surface);
        padding: 32px;
    }

    body {
        background: #f1f5f9;
        padding: 20px;
    }

    .app-header {
        position: static;
        background: transparent;
        border: none;
        backdrop-filter: none;
    }

    .header-content {
        padding: 0 0 20px 0;
    }
}