/* variables & base */
:root {
    --radius: 12px;
    --bg-dark-1: linear-gradient(135deg, #0f1724 0%, #18304a 60%, #0b1220 100%);
    --bg-dark-2: linear-gradient(135deg, #0b1220 0%, #0f2a44 60%, #06202b 100%);
    --accent: linear-gradient(90deg, #667eea, #764ba2);
    --glass: rgba(255, 255, 255, 0.06);
    --glass-2: rgba(255, 255, 255, 0.03);
    --text: #e6eef8;
    --muted: #a8c0d8;
    --success: #4ade80;
    --danger: #ff7676;
    --shadow: 0 8px 30px rgba(2, 6, 23, 0.6);
    --transition: 250ms cubic-bezier(.2, .9, .3, 1);
}

/* light theme overrides */
body.light {
    --bg-dark-1: linear-gradient(135deg, #f5f7fb 0%, #e6eef8 100%);
    --bg-dark-2: linear-gradient(135deg, #ffffff 0%, #f3f6fb 100%);
    --glass: rgba(10, 20, 30, 0.03);
    --glass-2: rgba(10, 20, 30, 0.02);
    --text: #0b1220;
    --muted: #556677;
    --shadow: 0 8px 30px rgba(20, 30, 50, 0.06);
}

/* page reset */
* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg-dark-1);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--transition), color var(--transition);
}

/* layout helpers */
.page {
    min-height: 100vh;
    display: flex;
    flex-direction: row;
}

.hidden {
    display: none !important;
}

/* kel chi auth hon kermel login/create account etc. */
.auth-page {
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 420px;
}

.auth-left {
    padding: 60px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-content: center;
}

.brand {
    max-width: 720px;
}

.brand-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.brand h1 {
    font-size: 2.2rem;
    margin: 12px 0;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--muted);
    max-width: 520px;
    margin-bottom: 18px;
}

.auth-card {
    width: 420px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.clear-data-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 118, 118, 0.1);
    border: 1px solid rgba(255, 118, 118, 0.2);
    color: var(--danger);
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all var(--transition);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-data-btn:hover {
    background: rgba(255, 118, 118, 0.2);
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 4px 12px rgba(255, 118, 118, 0.3);
}

.form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form h2 {
    margin-bottom: 6px;
    font-size: 1.2rem;
}

.field label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.field input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    background: transparent;
    color: var(--text);
    outline: none;
    transition: box-shadow var(--transition), transform var(--transition);
}

.field input:focus {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn {
    padding: 10px 14px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.btn.primary {
    background: var(--accent);
    color: white;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.14);
}

.btn.ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.auth-right {
    background: var(--bg-dark-2);
    padding: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-graphic {
    text-align: center;
    color: var(--muted);
    max-width: 360px;
}

.hero-graphic img {
    width: 220px;
    margin-top: 18px;
    opacity: 0.95;
    transform: translateY(0);
    transition: transform 600ms ease;
}

.hero-graphic:hover img {
    transform: translateY(-6px);
}

/* heda lal mobile responsive */
@media (max-width:980px) {
    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-right {
        display: none;
    }

    .auth-left {
        padding: 28px;
    }

    .auth-card {
        width: 100%;
    }
}

/* app header */
.app-page {
    flex-direction: column;
    min-height: 100vh;
    display: flex;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    gap: 10px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.12), rgba(255, 255, 255, 0.02));
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.app-header .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.05rem;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: 18px;
}

.controls input[type=search] {
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 280px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-size: 0.95rem;
    transition: all var(--transition);
}

.controls input[type=search]:focus {
    border-color: rgba(102, 126, 234, 0.4);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.controls input[type=search]::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

.controls select {
    padding: 10px 32px 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a8c0d8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    transition: all var(--transition);
}

.controls select:hover {
    border-color: rgba(102, 126, 234, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.controls select:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.controls select option {
    background: #0f1724;
    color: var(--text);
    padding: 8px;
}

body.light .controls select option {
    background: #ffffff;
    color: #0b1220;
}

.app-header .left {
    display: flex;
    flex-direction: column;
    /* heda  l flex direction houwe column ta ysiro ta7et ba3ed */
    align-items: flex-start;
    gap: 8px;
    /* heda l space between logo and search/sort fields */
}

/* user badge */
.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-badge #userLabel {
    font-size: 0.9rem;
    color: var(--muted);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: scale(1.05);
}

/* hayde l main layout */
.container {
    display: flex;
    gap: 18px;
    padding: 22px;
    flex: 1;
}

.panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.02));
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--shadow);
}

.left-panel {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* hon kel chi panel content metel l cards, actions w label etc. */
.panel-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filters {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 6px;
}

.filters label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.filters select,
.filters input[type=number] {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-size: 0.9rem;
    transition: all var(--transition);
}

.filters select:focus,
.filters input[type=number]:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.5);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filters .range {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filters .range input {
    flex: 1;
}

.stats-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 14px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-card h4 {
    margin: 0 0 10px 0;
    color: var(--text);
    font-size: 1rem;
}

.stats-card hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 10px 0;
}

.stats-card strong {
    color: var(--text);
}

/* heda lal books grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

/* heda lal book card */
.book {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform var(--transition), box-shadow var(--transition);
}

.book:hover {
    transform: translateY(-8px);
    box-shadow: 0 24px 60px rgba(2, 6, 23, 0.5);
}

.empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 1.1rem;
}

.book .cover {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    background: #10202a;
}

.book h3 {
    font-size: 1rem;
    margin: 0;
}

.meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

/* heda lal small buttons on card bass l user ya3mul create la book */
.card-actions {
    display: flex;
    gap: 6px;
}

.small {
    padding: 6px 8px;
    font-size: 0.9rem;
    border-radius: 8px;
}

/* heda lal rating stars */
.stars {
    display: flex;
    gap: 6px;
    align-items: center;
}

.stars button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.05rem;
}

/* heda lal modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 80;
    padding: 20px;
}

.modal-content {
    width: 100%;
    max-width: 540px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(2, 6, 23, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h3 {
    margin: 0 0 20px 0;
    font-size: 1.4rem;
    font-weight: 700;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-content label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.modal-content input[type=text],
.modal-content input[type=number],
.modal-content input[type=file] {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 0.95rem;
    transition: all var(--transition);
}

.modal-content input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.6);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.modal-content input[type=file] {
    padding: 10px;
    cursor: pointer;
}

.modal-content input::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 6px;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    color: white;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 200;
}

/* heda lal footer */
.app-footer {
    padding: 18px 24px;
    margin-top: auto;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.01));
    border-top: 1px solid rgba(255, 255, 255, 0.02);
}

.footer-inner {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    color: var(--muted);
}

.footer-inner a {
    color: var(--muted);
    text-decoration: none;
    margin: 0 6px;
}

.footer-inner a:hover {
    text-decoration: underline;
    color: var(--text);
}

/* heda to make l author links bold but ampersand not included in bold text so our names looks cool bel footer */
.footer-right strong a.author-link {
    color: inherit;
    text-decoration: none;
    font-weight: 700;
}

.footer-right a.author-link:hover {
    text-decoration: underline;
}

/* heda lal mobile responsive */
@media (max-width:980px) {
    .container {
        flex-direction: column;
        padding: 12px;
    }

    .left-panel {
        width: 100%;
        order: 2;
    }

    .right-panel {
        order: 1;
    }

    .controls input[type=search] {
        width: 100%;
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
    }

    .app-header .left {
        width: 100%;
    }

    .app-header .right {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    #userBadge {
        margin-right: auto;
        order: 1;
        margin-left: 5%;
    }

    .theme-toggle {
        order: 2;
    }

    #logout {
        order: 3;
    }
}

/* heda lal mobile responsive */
@media (max-width:520px) {
    .auth-left {
        padding: 18px;
    }

    .brand h1 {
        font-size: 1.5rem;
    }

    .books-grid {
        grid-template-columns: 1fr;
    }
}

#JoeAbbasBatoul {
    color: #e6eef8;
    text-decoration: none;
}

#JoeAbbasBatoul:hover {
    text-decoration: underline;
}

/* heda lal form error messages */
.form-error {
    min-height: 20px;
    /* prevents layout shift */
    color: var(--danger);
    font-size: 0.9rem;
    margin-bottom: 8px;
    opacity: 0;
    transform-origin: left;
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none;
}

.form-error.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.year-input {
    width: 75px;
}

.logo-img {
    width: 25px;
    height: 25px;
    margin-right: 8px;
    border-radius: 25%;
}