*, *:before, *:after {
    box-sizing: border-box;
}

:root {
    --color-bg: #f6f3ea;
    --color-surface: #ffffff;
    --color-ink: #16302b;
    --color-ink-muted: #5c6f68;
    --color-primary: #0f4c42;
    --color-primary-dark: #0a3430;
    --color-gold: #b8902f;
    --color-gold-soft: #e3cd8f;
    --color-border: #e1dcc8;
    --color-current: #b8562f;
}

html, body {
    height: 100%;
}

body {
    line-height: 1.4;
    font-family: 'Inter', sans-serif;
    color: var(--color-ink);
    background-color: var(--color-bg);
    background-image:
        radial-gradient(circle at 1px 1px, rgba(15, 76, 66, 0.08) 1px, transparent 0),
        linear-gradient(160deg, #f8f5ec 0%, #f1ecda 100%);
    background-size: 24px 24px, 100% 100%;
    margin: 0;
    overflow: hidden;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.app-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: clamp(1rem, 4vh, 2rem) 1.25rem 0.875rem;
}

.app-bar__brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.app-bar__icon {
    font-size: 1.375rem;
    line-height: 1;
    color: var(--color-gold);
}

.app-bar__title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-primary-dark);
    white-space: nowrap;
}

.location-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 24rem;
}

.location-search__input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 0.5rem 0.875rem;
    font: inherit;
    background: var(--color-surface);
    color: var(--color-ink);
}

.location-search__locate {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
    color: var(--color-primary);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.location-search__locate:hover {
    background: #f4f1e4;
    border-color: var(--color-primary);
}

.location-search__locate:disabled,
.location-search__locate--busy {
    opacity: 0.6;
    cursor: wait;
}

.location-search__input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(15, 76, 66, 0.15);
}

.location-search__dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.25rem);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    max-height: 18rem;
    overflow: auto;
    z-index: 5;
    box-shadow: 0 10px 30px rgba(22, 48, 43, 0.12);
}

.location-search__results {
    list-style: none;
    margin: 0;
    padding: 0;
}

.location-search__item {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
    text-align: left;
    padding: 0.625rem 0.75rem;
    font: inherit;
    cursor: pointer;
    color: var(--color-ink);
}

.location-search__item:hover {
    background: #f4f1e4;
}

.location-search__state {
    padding: 0.75rem;
    color: var(--color-ink-muted);
}

@media (max-width: 640px) {
    .app-bar {
        flex-direction: column;
        gap: 0.625rem;
        padding: clamp(1rem, 4vh, 2rem) 1rem 0.75rem;
    }
}

p {
    margin: 0;
}

p + p {
    margin-top: 0.5rem;
}

.text--numeric {
    font-variant: tabular-nums;
    letter-spacing: -0.03em;
}

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

.text--arabic {
    font-family: 'Noto Sans Arabic', Inter, sans-serif;
    line-height: 1;
}

.text--time {
    font-size: 1.5em;
}

.app-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    gap: clamp(0.5rem, 2vh, 1.25rem);
    padding: clamp(0.5rem, 2vh, 1rem) 1rem;
    overflow: hidden;
}

.table-wrapper {
    flex: 0 1 auto;
    min-height: 0;
    overflow: auto;
    width: 100%;
    max-width: 34rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(22, 48, 43, 0.08);
}

@media (max-width: 768px) {
    .table-wrapper {
        max-width: 100%;
    }

    .salath-table {
        font-size: 1.25rem;
    }

    .clock {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    .salath-table {
        table-layout: fixed;
    }

    .cell-names {
        width: 62%;
        white-space: normal;
        overflow: hidden;
    }

    .cell-times {
        width: 38%;
    }

    .salath-name-alternatives {
        display: none;
    }
}

.salath-table {
    font-size: clamp(1.1rem, 2.4vh, 1.625rem);
    font-weight: 600;

    width: 100%;
    vertical-align: middle;
    border-collapse: collapse;
}

td {
    padding: clamp(0.4rem, 1.3vh, 0.75rem) 1.25rem;
}

tr.salath + tr.salath td {
    border-top: 1px solid var(--color-border);
}

.cell-names {
    padding-right: 0.5rem;
    white-space: nowrap;
    color: var(--color-primary-dark);
}

.cell-times {
    padding-left: 0.5rem;
    white-space: nowrap;
    text-align: right;
    color: var(--color-ink);
}

.salath-name-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
}
.salath-name-alternatives {
    line-height: 1.1;
}
.salath-name-alternatives span + span:before {
    content: " / ";
    opacity: 0.5;
}

.salath-name-group--center {
    align-items: center;
}

.salath-name--primary {
    line-height: 1.05;
}

.salath-name--secondary {
    font-size: 0.58em;
    font-weight: 500;
    opacity: 0.75;
    line-height: 1.1;
}

.current {
    color: var(--color-current);
}

tr.current td {
    background: #faf4e3;
}

tr.current .cell-names {
    box-shadow: inset 4px 0 0 var(--color-gold);
}

.salath-time {
    font-weight: 700;
}

.app-footer {
    flex: 0 0 auto;
    padding: clamp(0.5rem, 2vh, 1rem) 1rem clamp(1rem, 4vh, 2rem);
}

.clock {
    font-size: clamp(1.75rem, 5vh, 3rem);
    font-weight: bold;
    color: var(--color-primary-dark);
}

.current-salath {
    flex: 0 0 auto;
    font-weight: bold;
    font-size: clamp(0.95rem, 2.2vh, 1.25rem);
    color: var(--color-primary);
}
