/* Ephemeris - Combined Styles (Base + Ephemeris-specific) */
/* Light Theme (default) + Dark Theme */

:root {
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Light theme */
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-header: #ffffff;
    --bg-footer: #f9fafb;
    --bg-table-header: #f8fafc;
    --bg-table-row-alt: #fafafa;
    --bg-highlight: #f1f5f9;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-header: #111827;
    --text-label: #374151;

    --border-color: #e2e8f0;
    --border-input: #d1d5db;
    --border-focus: #000000;

    --btn-primary-bg: #0f172a;
    --btn-primary-text: #ffffff;
    --btn-primary-hover: #1e293b;
    --btn-small-bg: #f1f5f9;
    --btn-small-text: #374151;

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.08);

    --retrograde-color: #dc2626;
    --sig-color: #059669;

    --radius: 8px;
    --radius-sm: 6px;
    --radius-xl: 12px;
}

html.dark {
    --bg-primary: #000000;
    --bg-card: #0a0a0a;
    --bg-input: #1a1a1a;
    --bg-header: #000000;
    --bg-footer: #000000;
    --bg-table-header: #111111;
    --bg-table-row-alt: #0a0a0a;
    --bg-highlight: #1a1a1a;

    --text-primary: #f0f0f0;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-header: #f0f0f0;
    --text-label: #d4d4d8;

    --border-color: #262626;
    --border-input: #404040;
    --border-focus: #f0f0f0;

    --btn-primary-bg: #f0f0f0;
    --btn-primary-text: #000000;
    --btn-primary-hover: #d4d4d4;
    --btn-small-bg: #1a1a1a;
    --btn-small-text: #d4d4d8;

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.3);

    --retrograde-color: #ef4444;
    --sig-color: #10b981;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    line-height: 1.5;
}

/* ==================== HEADER ==================== */

.header {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-header);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    height: 56px;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo-container img { height: 28px; width: auto; }
.logo-light { display: block; }
.logo-dark { display: none; }
html.dark .logo-light { display: none; }
html.dark .logo-dark { display: block; }

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

.header-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    white-space: nowrap;
}

.header-spacer { flex: 1; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-ok {
    color: var(--sig-color);
    font-size: 0.78rem;
}

.status-error {
    color: var(--retrograde-color);
    font-size: 0.78rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-highlight);
    color: var(--text-primary);
    border-color: var(--border-input);
}

.icon-btn svg { width: 18px; height: 18px; }
.sun-icon { display: block; }
.moon-icon { display: none; }
html.dark .sun-icon { display: none; }
html.dark .moon-icon { display: block; }

/* ==================== MAIN ==================== */

.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    width: 100%;
    flex: 1;
}

/* ==================== INPUT SECTION ==================== */

.input-section {
    margin-bottom: 16px;
}

.input-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 16px 20px;
    box-shadow: var(--shadow-card);
}

.input-field {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-family);
    outline: none;
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 1px var(--border-focus);
}

select.input-field {
    cursor: pointer;
    appearance: auto;
}

.btn-primary {
    height: 36px;
    padding: 0 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
    background: var(--btn-primary-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== LOCATION SEARCH ==================== */

.location-search-wrapper {
    position: relative;
}

.location-pin-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.location-input {
    padding-left: 28px !important;
}

.location-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    margin-top: 4px;
    display: none;
}

.location-dropdown.active {
    display: block;
}

.loc-item {
    padding: 8px 12px;
    font-size: 12.5px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}

.loc-item:last-child {
    border-bottom: none;
}

.loc-item:hover {
    background: var(--bg-highlight);
}

.loc-empty {
    color: var(--text-muted);
    cursor: default;
    text-align: center;
}

/* ==================== RESULTS SECTION ==================== */

.results-section {
    margin-top: 16px;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
}

/* ==================== FOOTER ==================== */

.app-footer {
    text-align: center;
    padding: 16px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: var(--bg-footer);
    margin-top: auto;
}

/* ======================================================================================== */
/* EPHEMERIS-SPECIFIC STYLES                                                                 */
/* ======================================================================================== */

/* ==================== FORM ROW ==================== */

.eph-form-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.eph-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.eph-field label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.eph-field-btn {
    justify-content: flex-end;
}

.eph-field-location {
    flex: 1;
    min-width: 200px;
}

.eph-field .input-field {
    min-width: 160px;
}

.eph-field select.input-field {
    min-width: 200px;
}

/* ==================== QUICK RANGE BUTTONS ==================== */

.eph-quick-range {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.eph-quick-range .btn-small {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--btn-small-bg);
    color: var(--btn-small-text);
    transition: all 0.15s ease;
}

.eph-quick-range .btn-small:hover {
    background: var(--bg-highlight);
    border-color: var(--border-input);
}

.eph-quick-range .btn-small.active {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border-color: var(--btn-primary-bg);
}

/* ==================== SUMMARY BAR ==================== */

.eph-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    box-shadow: var(--shadow-card);
}

.eph-summary-actions {
    display: flex;
    gap: 8px;
}

.eph-summary-actions .btn-small {
    font-size: 11px;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--btn-small-bg);
    color: var(--btn-small-text);
}

.eph-summary-actions .btn-small:hover {
    background: var(--bg-highlight);
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--btn-primary-bg);
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    transition: all 0.15s ease;
}

.btn-download:hover {
    background: var(--btn-primary-hover);
}

.btn-download svg {
    flex-shrink: 0;
}

/* ==================== EPHEMERIS TABLE ==================== */

.eph-table-card {
    padding: 0;
    overflow: hidden;
}

.eph-table-wrapper {
    overflow-x: auto;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

.eph-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}

.eph-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.eph-table thead th {
    background: var(--bg-table-header);
    border-bottom: 2px solid var(--border-color);
    padding: 8px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
}

.eph-table tbody td {
    border-bottom: 1px solid var(--border-color);
    padding: 5px 8px;
    vertical-align: middle;
    white-space: nowrap;
}

.eph-table tbody tr:nth-child(even) {
    background: var(--bg-table-row-alt);
}

/* ==================== STICKY COLUMNS ==================== */

.eph-sno-col {
    position: sticky;
    left: 0;
    z-index: 11;
    background: var(--bg-table-header);
    min-width: 40px;
    border-right: 1px solid var(--border-color);
}

.eph-date-col {
    position: sticky;
    left: 40px;
    z-index: 11;
    background: var(--bg-table-header);
    text-align: left !important;
    padding-left: 10px !important;
    min-width: 100px;
    border-right: 1px solid var(--border-color);
}

.eph-sno-cell {
    position: sticky;
    left: 0;
    z-index: 5;
    background: var(--bg-card);
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    border-right: 1px solid var(--border-color);
    min-width: 40px;
}

.eph-date-cell {
    position: sticky;
    left: 40px;
    z-index: 5;
    background: var(--bg-card);
    font-weight: 500;
    font-size: 11.5px;
    color: var(--text-primary);
    padding-left: 10px !important;
    border-right: 1px solid var(--border-color);
    min-width: 100px;
}

/* Alternate row bg for sticky cells */
.eph-table tbody tr:nth-child(even) .eph-sno-cell,
.eph-table tbody tr:nth-child(even) .eph-date-cell {
    background: var(--bg-table-row-alt);
}

/* ==================== TIME COLUMN ==================== */

.eph-time-col {
    min-width: 70px;
}

.eph-time-cell {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
}

/* ==================== PLANET LONGITUDE CELLS ==================== */

.eph-planet-hdr {
    min-width: 110px;
    font-weight: 700;
}

.eph-lon-cell {
    text-align: center;
    font-size: 11.5px;
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
    color: var(--text-primary);
}

/* ==================== RETROGRADE CELLS ==================== */

.eph-retro-hdr {
    min-width: 36px;
    font-size: 11px !important;
}

.eph-retro-cell {
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-muted);
}

.eph-retro-r {
    color: var(--retrograde-color) !important;
    font-weight: 700;
}

/* ==================== HOUSE CUSP CELLS ==================== */

.eph-cusp-hdr {
    min-width: 90px;
    font-size: 11px !important;
    color: var(--text-secondary) !important;
}

.eph-cusp-cell {
    text-align: center;
    font-size: 11px;
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
    color: var(--text-secondary);
}

/* ==================== SIGN SYMBOL COLORS ==================== */

/* Fire signs */
.eph-sign-0, .eph-sign-4, .eph-sign-8 { color: #dc2626; }
html.dark .eph-sign-0, html.dark .eph-sign-4, html.dark .eph-sign-8 { color: #f87171; }
/* Earth signs */
.eph-sign-1, .eph-sign-5, .eph-sign-9 { color: #16a34a; }
html.dark .eph-sign-1, html.dark .eph-sign-5, html.dark .eph-sign-9 { color: #4ade80; }
/* Air signs */
.eph-sign-2, .eph-sign-6, .eph-sign-10 { color: #2563eb; }
html.dark .eph-sign-2, html.dark .eph-sign-6, html.dark .eph-sign-10 { color: #60a5fa; }
/* Water signs */
.eph-sign-3, .eph-sign-7, .eph-sign-11 { color: #9333ea; }
html.dark .eph-sign-3, html.dark .eph-sign-7, html.dark .eph-sign-11 { color: #c084fc; }

/* ==================== SIGN CHANGE HIGHLIGHT ==================== */

.eph-sign-change {
    background: rgba(37, 99, 235, 0.08) !important;
    border-left: 2px solid #2563eb;
}

html.dark .eph-sign-change {
    background: rgba(96, 165, 250, 0.12) !important;
    border-left: 2px solid #60a5fa;
}

/* ==================== TODAY ROW HIGHLIGHT ==================== */

.eph-today-row td {
    background: #fef9c3 !important;
}

html.dark .eph-today-row td {
    background: #3a2a04 !important;
}

.eph-today-row .eph-sno-cell,
.eph-today-row .eph-date-cell {
    background: #fef3c7 !important;
}

html.dark .eph-today-row .eph-sno-cell,
html.dark .eph-today-row .eph-date-cell {
    background: #422006 !important;
}

/* ==================== LOADING OVERLAY ==================== */

.eph-loading {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

html.dark .eph-loading {
    background: rgba(0, 0, 0, 0.7);
}

.eph-loading-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 32px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    min-width: 320px;
}

.eph-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--btn-primary-bg);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.eph-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.eph-progress-fill {
    height: 100%;
    background: var(--btn-primary-bg);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    .eph-form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .eph-field .input-field,
    .eph-field select.input-field {
        min-width: auto;
        width: 100%;
    }

    .eph-table {
        font-size: 11px;
    }

    .eph-summary-bar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .header-subtitle {
        display: none;
    }
}

@media (max-width: 480px) {
    .eph-quick-range {
        gap: 4px;
    }

    .eph-quick-range .btn-small {
        font-size: 10px;
        padding: 3px 8px;
    }
}
