/* ══════════════════════════════════════════════════════
   e-Cities — Base Styles
   Global layout, components, utilities.
   ══════════════════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--ec-font-body);
    font-size: var(--ec-text-base);
    line-height: 1.6;
    color: var(--ec-text);
    background: var(--ec-bg);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Skip link (accessibility) ── */
.ec-skip-link {
    position: absolute;
    top: -100%;
    left: var(--ec-space-4);
    background: var(--ec-primary);
    color: var(--ec-text-inverse);
    padding: var(--ec-space-2) var(--ec-space-4);
    border-radius: var(--ec-radius-md);
    z-index: var(--ec-z-toast);
    font-weight: 600;
    text-decoration: none;
}
.ec-skip-link:focus {
    top: var(--ec-space-4);
}

/* ── Layout ── */
.ec-container {
    width: 100%;
    max-width: var(--ec-max-width);
    margin: 0 auto;
    padding: 0 var(--ec-space-4);
}

.ec-main {
    flex: 1;
}

/* ── Header ── */
.ec-header {
    position: sticky;
    top: 0;
    z-index: var(--ec-z-sticky);
    height: var(--ec-header-h);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--ec-border);
    display: flex;
    align-items: center;
    transition: background var(--ec-transition-normal);
}

.ec-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--ec-max-width);
    margin: 0 auto;
    padding: 0 var(--ec-space-4);
    gap: var(--ec-space-4);
}

.ec-header__logo {
    display: flex;
    align-items: center;
    gap: var(--ec-space-2);
    text-decoration: none;
    font-weight: 700;
    font-size: var(--ec-text-xl);
    color: var(--ec-primary);
}

.ec-header__logo img {
    height: 32px;
    width: auto;
}

.ec-header__nav {
    display: flex;
    align-items: center;
    gap: var(--ec-space-2);
}

.ec-header__search {
    flex: 1;
    max-width: 480px;
}

/* ── Footer ── */
.ec-footer {
    background: var(--ec-bg-secondary);
    border-top: 1px solid var(--ec-border);
    padding: var(--ec-space-12) 0 var(--ec-space-6);
    margin-top: auto;
}

.ec-footer__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--ec-space-8);
    margin-bottom: var(--ec-space-8);
}

.ec-footer__col h4 {
    font-size: var(--ec-text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ec-text-secondary);
    margin-bottom: var(--ec-space-3);
}

.ec-footer__col a {
    display: block;
    color: var(--ec-text-secondary);
    text-decoration: none;
    padding: var(--ec-space-1) 0;
    font-size: var(--ec-text-sm);
    transition: color var(--ec-transition-fast);
}

.ec-footer__col a:hover {
    color: var(--ec-primary);
}

.ec-footer__bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--ec-space-4);
    padding-top: var(--ec-space-6);
    border-top: 1px solid var(--ec-border);
    font-size: var(--ec-text-sm);
    color: var(--ec-text-muted);
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--ec-font-heading);
    line-height: 1.2;
    color: var(--ec-text);
}
h1 { font-size: var(--ec-text-4xl); font-weight: 800; }
h2 { font-size: var(--ec-text-3xl); font-weight: 700; }
h3 { font-size: var(--ec-text-2xl); font-weight: 700; }
h4 { font-size: var(--ec-text-xl);  font-weight: 600; }

a {
    color: var(--ec-primary);
    text-decoration: none;
    transition: color var(--ec-transition-fast);
}
a:hover { color: var(--ec-primary-dark); }

/* ── Buttons ── */
.ec-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ec-space-2);
    padding: var(--ec-space-3) var(--ec-space-6);
    min-height: var(--ec-touch-min);
    border: none;
    border-radius: var(--ec-radius-md);
    font-family: var(--ec-font-body);
    font-size: var(--ec-text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ec-transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.ec-btn-primary {
    background: var(--ec-primary);
    color: var(--ec-text-inverse);
}
.ec-btn-primary:hover {
    background: var(--ec-primary-dark);
    color: var(--ec-text-inverse);
}

.ec-btn-secondary {
    background: var(--ec-bg);
    color: var(--ec-text);
    border: 1px solid var(--ec-border-strong);
}
.ec-btn-secondary:hover {
    background: var(--ec-bg-secondary);
}

.ec-btn-accent {
    background: var(--ec-accent);
    color: #1a1a1a;
}
.ec-btn-accent:hover {
    background: var(--ec-accent-light);
}

.ec-btn-ghost {
    background: transparent;
    color: var(--ec-text-secondary);
}
.ec-btn-ghost:hover {
    background: var(--ec-bg-tertiary);
    color: var(--ec-text);
}

.ec-btn-sm {
    padding: var(--ec-space-2) var(--ec-space-4);
    font-size: var(--ec-text-xs);
    min-height: 36px;
}

.ec-btn-lg {
    padding: var(--ec-space-4) var(--ec-space-8);
    font-size: var(--ec-text-base);
    min-height: 52px;
}

.ec-btn-icon {
    padding: var(--ec-space-2);
    min-width: var(--ec-touch-min);
    min-height: var(--ec-touch-min);
}

/* ── Cards ── */
.ec-card {
    background: var(--ec-surface);
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-radius-lg);
    padding: var(--ec-space-6);
    transition: box-shadow var(--ec-transition-normal);
}
.ec-card:hover {
    box-shadow: var(--ec-shadow-md);
}

.ec-card--listing {
    padding: 0;
    overflow: hidden;
    cursor: pointer;
}

.ec-card--listing .ec-card__img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
}

.ec-card--listing .ec-card__body {
    padding: var(--ec-space-4);
}

.ec-card--listing .ec-card__price {
    font-size: var(--ec-text-lg);
    font-weight: 700;
    color: var(--ec-text);
}

.ec-card--listing .ec-card__title {
    font-size: var(--ec-text-sm);
    color: var(--ec-text-secondary);
    margin-top: var(--ec-space-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ec-card--listing .ec-card__meta {
    display: flex;
    align-items: center;
    gap: var(--ec-space-2);
    margin-top: var(--ec-space-2);
    font-size: var(--ec-text-xs);
    color: var(--ec-text-muted);
}

/* ── Forms ── */
.ec-input,
.ec-select,
.ec-textarea {
    width: 100%;
    padding: var(--ec-space-3) var(--ec-space-4);
    min-height: var(--ec-touch-min);
    background: var(--ec-bg);
    border: 1px solid var(--ec-border-strong);
    border-radius: var(--ec-radius-md);
    font-family: var(--ec-font-body);
    font-size: var(--ec-text-base);
    color: var(--ec-text);
    transition: border-color var(--ec-transition-fast), box-shadow var(--ec-transition-fast);
}

.ec-input:focus,
.ec-select:focus,
.ec-textarea:focus {
    outline: none;
    border-color: var(--ec-primary);
    box-shadow: 0 0 0 3px var(--ec-primary-subtle);
}

.ec-input::placeholder,
.ec-textarea::placeholder {
    color: var(--ec-text-muted);
}

.ec-label {
    display: block;
    font-size: var(--ec-text-sm);
    font-weight: 500;
    color: var(--ec-text);
    margin-bottom: var(--ec-space-1);
}

.ec-form-group {
    margin-bottom: var(--ec-space-4);
}

/* ── Search bar ── */
.ec-search-bar {
    display: flex;
    align-items: center;
    background: var(--ec-bg-secondary);
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-radius-full);
    padding: var(--ec-space-1) var(--ec-space-2);
    transition: border-color var(--ec-transition-fast), box-shadow var(--ec-transition-fast);
}

.ec-search-bar:focus-within {
    border-color: var(--ec-primary);
    box-shadow: 0 0 0 3px var(--ec-primary-subtle);
}

.ec-search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    padding: var(--ec-space-2) var(--ec-space-3);
    font-size: var(--ec-text-sm);
    color: var(--ec-text);
    outline: none;
}

.ec-search-bar input::placeholder {
    color: var(--ec-text-muted);
}

/* ── Badges ── */
.ec-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--ec-space-1);
    padding: var(--ec-space-1) var(--ec-space-2);
    border-radius: var(--ec-radius-full);
    font-size: var(--ec-text-xs);
    font-weight: 600;
    background: var(--ec-primary-subtle);
    color: var(--ec-primary-dark);
}

.ec-badge--success { background: #DCFCE7; color: #166534; }
.ec-badge--warning { background: #FEF3C7; color: #92400E; }
.ec-badge--danger  { background: #FEE2E2; color: #991B1B; }
.ec-badge--info    { background: #DBEAFE; color: #1E40AF; }

/* ── Grid layouts ── */
.ec-grid {
    display: grid;
    gap: var(--ec-space-4);
}

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

.ec-grid-listings {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

/* ── Toast notifications ── */
.ec-toast-container {
    position: fixed;
    bottom: var(--ec-space-6);
    right: var(--ec-space-6);
    z-index: var(--ec-z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--ec-space-2);
}

.ec-toast {
    background: var(--ec-surface);
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-radius-md);
    padding: var(--ec-space-3) var(--ec-space-4);
    box-shadow: var(--ec-shadow-lg);
    min-width: 280px;
    max-width: 400px;
    animation: ec-slide-in 0.2s ease;
}

@keyframes ec-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ── Utilities ── */
.ec-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ec-text-center { text-align: center; }
.ec-text-muted  { color: var(--ec-text-muted); }
.ec-mt-4 { margin-top: var(--ec-space-4); }
.ec-mt-8 { margin-top: var(--ec-space-8); }
.ec-mb-4 { margin-bottom: var(--ec-space-4); }
.ec-mb-8 { margin-bottom: var(--ec-space-8); }
.ec-flex  { display: flex; }
.ec-flex-col { flex-direction: column; }
.ec-items-center { align-items: center; }
.ec-justify-between { justify-content: space-between; }
.ec-gap-2 { gap: var(--ec-space-2); }
.ec-gap-4 { gap: var(--ec-space-4); }
.ec-hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .ec-grid-2, .ec-grid-3, .ec-grid-4 { grid-template-columns: 1fr; }
    .ec-grid-listings { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

    .ec-header__search { display: none; }

    .ec-container { padding: 0 var(--ec-space-3); }

    h1 { font-size: var(--ec-text-3xl); }
    h2 { font-size: var(--ec-text-2xl); }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .ec-grid-4 { grid-template-columns: repeat(3, 1fr); }
}
