/* Question Paper Repository - Modern CSS */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette */
    --primary: hsl(220, 90%, 56%);
    --primary-dark: hsl(220, 90%, 46%);
    --primary-light: hsl(220, 90%, 96%);
    --secondary: hsl(280, 70%, 60%);
    --accent: hsl(160, 70%, 50%);

    --bg-primary: hsl(220, 20%, 98%);
    --bg-secondary: hsl(220, 15%, 95%);
    --bg-card: hsl(0, 0%, 100%);

    --text-primary: hsl(220, 20%, 15%);
    --text-secondary: hsl(220, 15%, 45%);
    --text-muted: hsl(220, 10%, 65%);

    --border: hsl(220, 15%, 90%);
    --shadow: 0 2px 8px hsla(220, 20%, 20%, 0.08);
    --shadow-lg: 0 8px 24px hsla(220, 20%, 20%, 0.12);

    --success: hsl(140, 65%, 50%);
    --warning: hsl(40, 90%, 55%);
    --error: hsl(0, 75%, 60%);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: hsl(220, 20%, 12%);
        --bg-secondary: hsl(220, 18%, 16%);
        --bg-card: hsl(220, 18%, 18%);

        --text-primary: hsl(220, 20%, 95%);
        --text-secondary: hsl(220, 15%, 70%);
        --text-muted: hsl(220, 10%, 50%);

        --border: hsl(220, 15%, 25%);
        --shadow: 0 2px 8px hsla(0, 0%, 0%, 0.3);
        --shadow-lg: 0 8px 24px hsla(0, 0%, 0%, 0.4);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5em;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.logo-main {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-sub {
    font-weight: 400;
    font-size: 0.65em;
    color: var(--text-secondary);
    opacity: 0.85;
    white-space: nowrap;
}

/* Mobile logo adjustments */
@media (max-width: 768px) {
    .logo {
        font-size: 1.25rem;
        gap: 0.25rem;
    }

    .logo-sub {
        font-size: 0.6em;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.1rem;
    }

    .logo-sub {
        font-size: 0.55em;
    }
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.nav-links a:hover {
    color: var(--primary);
}

/* Search Bar */
.search-section {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 4rem 0;
    text-align: center;
    color: white;
}

.search-section h1 {
    margin-bottom: 1rem;
    font-size: 2.5rem;
}

.search-section p {
    opacity: 0.9;
    margin-bottom: 2rem;
}

.search-container {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 1rem 3.5rem 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition);
}

.search-input:focus {
    outline: none;
    transform: translateY(-2px);
}

.search-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: background var(--transition);
}

.search-btn:hover {
    background: var(--primary-dark);
}

/* Filters */
.filters {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 2rem 0;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color var(--transition);
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

/* Paper Card */
.paper-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
    transition: transform var(--transition), box-shadow var(--transition);
}

.paper-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-lg);
}

.paper-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.paper-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.paper-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.paper-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.paper-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.paper-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Stats Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label {
    opacity: 0.9;
    font-size: 0.95rem;
}

/* Table */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin: 2rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg-secondary);
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background: var(--bg-secondary);
}

/* Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: hsla(0, 0%, 0%, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* Alert */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: hsla(140, 65%, 50%, 0.1);
    color: var(--success);
    border-left: 4px solid var(--success);
}

.alert-error {
    background: hsla(0, 75%, 60%, 0.1);
    color: var(--error);
    border-left: 4px solid var(--error);
}

.alert-warning {
    background: hsla(40, 90%, 55%, 0.1);
    color: var(--warning);
    border-left: 4px solid var(--warning);
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .container {
        padding: 0 1rem;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding: 0.75rem 0;
    }

    .logo {
        font-size: 1.25rem;
    }

    .nav-links {
        gap: 0.75rem;
        font-size: 0.875rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .search-section {
        padding: 2rem 0;
    }

    .search-section h1 {
        font-size: 1.75rem;
    }

    .search-input {
        padding: 0.875rem 3rem 0.875rem 1rem;
        font-size: 0.95rem;
    }

    .search-btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .filters {
        flex-direction: column;
        gap: 0.75rem;
    }

    .filter-group {
        min-width: 100%;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1.5rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    .paper-card {
        padding: 1.25rem;
    }

    .paper-title {
        font-size: 1rem;
    }

    .paper-meta {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .paper-footer {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .paper-footer .btn {
        width: 100%;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
        font-size: 0.875rem;
    }

    th,
    td {
        padding: 0.75rem 0.5rem;
    }

    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
        max-height: 85vh;
    }

    .card {
        padding: 1.25rem;
    }

    /* Touch-friendly tap targets */
    .btn,
    .nav-links a,
    .modal-close {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Better form inputs on mobile */
    .form-control,
    .search-input {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .container,
    .container-wide {
        padding: 0 0.75rem;
    }

    .search-section {
        padding: 1.5rem 0;
    }

    .search-section h1 {
        font-size: 1.5rem;
    }

    .search-section p {
        font-size: 0.875rem;
    }

    .search-container {
        flex-direction: column;
    }

    .search-btn {
        position: static;
        transform: none;
        width: 100%;
        margin-top: 0.5rem;
        border-radius: var(--radius-sm);
    }

    .search-input {
        padding: 0.875rem 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .paper-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    .nav-links {
        width: 100%;
    }

    .nav-links li {
        flex: 1;
        text-align: center;
    }

    /* Stack buttons vertically on very small screens */
    .flex.gap-2 {
        flex-direction: column;
    }

    .flex.gap-2 .btn {
        width: 100%;
    }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .search-section {
        padding: 1rem 0;
    }

    .modal-content {
        max-height: 90vh;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    /* Sharper borders and shadows */
    .card,
    .paper-card,
    .btn {
        box-shadow: 0 1px 3px hsla(220, 20%, 20%, 0.12);
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mt-4 {
    margin-top: 2rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

.hidden {
    display: none;
}

.flex {
    display: flex;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}