/* main.css – updated responsive, dark-mode, mobile fixes */

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

/* theme variables */
:root {
    --color-bg: #fffdfa;
    --color-text: #22223b;
    --color-primary: #0e5267;
    --color-secondary: #ffb703;
    --color-accent: #006b50;
    --color-muted: #8d99ae;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #181926;
        --color-text: #ececec;
        --color-primary: #0e5267;
        --color-secondary: #c38509;
        --color-accent: #000000;
        --color-muted: #b0b4bc;
    }
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    font-size: 1rem;
}

/* header */
header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--color-primary);
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

/* search form */
header form {
    display: flex;
    width: 100%;
    max-width: 600px;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#query {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--color-muted);
    border-radius: 4px;
    background: var(--color-bg);
    color: var(--color-text);
}

button {
    padding: 0.6rem 1.2rem;
    border: none;
    background: var(--color-accent);
    color: #fff;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

button:hover,
button:focus {
    background: var(--color-secondary);
}

/* main container */
.main-content {
    max-width: 1024px;
    margin: 1rem auto;
    padding: 0 1rem;
}

.results,
.recent-queries {
    margin-top: 1rem;
}

/* recent queries list */
.recent-queries h2 {
    margin-bottom: 0.75rem;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 1.25rem;
}

.query-list a {
    display: inline-block;
    margin: 0.25rem;
    padding: 0.35rem 0.6rem;
    background: var(--color-secondary);
    color: #fff;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
}

/* pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.page-link {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-muted);
    border-radius: 4px;
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
}

.page-link.current {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.page-link.disabled {
    pointer-events: none;
    color: var(--color-muted);
    border-color: var(--color-muted);
}

/* table styling */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

table th,
table td {
    padding: 0.6rem;
    text-align: left;
}

table th {
    background: var(--color-secondary);
    color: #fff;
    font-weight: 600;
}

table tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.03);
}

/* responsive tables: horizontal scroll on mobile */
@media (max-width: 600px) {
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        margin-top: 1rem;
    }

    table thead,
    table tbody,
    table tr {
        display: table-row-group;
    }

    table th,
    table td {
        display: table-cell;
        padding: 0.4rem 0.6rem;
        white-space: nowrap;
        vertical-align: middle;
    }

    body {
        font-size: 0.95rem;
    }
}

/* very narrow screens */
@media (max-width: 400px) {
    header {
        padding: 0.5rem;
    }

    #query {
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    button {
        font-size: 0.9rem;
        padding: 0.5rem 0.8rem;
        width: 100%;
    }
}

/* modal */
.modal {
    display: none;
    position: fixed;
    z-index: 999;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background: var(--color-bg);
    margin: 10% auto;
    border-radius: 4px;
    width: 80%;
    max-width: 600px;
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-150px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header,
.modal-footer {
    padding: 0.75rem 1rem;
    background: var(--color-primary);
    color: #fff;
}

.modal-body {
    padding: 1rem;
}

.close {
    float: right;
    font-size: 1.4rem;
    cursor: pointer;
}

/* legacy commented rule preserved */
/* // table td:nth-child(2) { font-family: Verdana; } */