/* Custom CSS - BMKG Earthquake Monitor */
/* Built with a modern, glassmorphic dark design system */

:root {
    /* Default: Light Theme Variables */
    --bg-main: #f1f5f9;
    --bg-sidebar: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: rgba(15, 23, 42, 0.08);
    --card-hover-border: rgba(99, 102, 241, 0.5);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --color-primary: #6366f1; /* Indigo */
    --color-primary-hover: #4f46e5;
    --color-accent: #06b6d4; /* Cyan */
    --color-accent-hover: #0891b2;
    --color-danger: #ef4444; /* Red */
    --color-warning: #f59e0b; /* Amber */
    --color-success: #10b981; /* Emerald */

    /* Theme-specific Leaflet Popup configurations */
    --popup-bg: #ffffff;
    --popup-text: #0f172a;
    --popup-border: rgba(15, 23, 42, 0.1);
}

body.dark-theme {
    /* Dark Theme Variables */
    --bg-main: #0b0f19;
    --bg-sidebar: #111827;
    --card-bg: rgba(30, 41, 59, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover-border: rgba(99, 102, 241, 0.4);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Theme-specific Leaflet Popup configurations */
    --popup-bg: #1e293b;
    --popup-text: #f8fafc;
    --popup-border: rgba(255, 255, 255, 0.15);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* App Container */
.app-container {
    height: 100%;
    width: 100%;
}

/* Dashboard Grid Layout */
.dashboard-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Sidebar Styling */
.sidebar {
    width: 400px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 1000;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--card-border);
}

.brand-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.btn-theme-toggle {
    background: rgba(99, 102, 241, 0.1);
    color: var(--color-primary);
    border: 1px solid rgba(99, 102, 241, 0.15);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease-in-out;
}

.btn-theme-toggle:hover {
    background: var(--color-primary);
    color: #ffffff;
    transform: scale(1.05);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-icon {
    font-size: 32px;
    color: var(--color-accent);
    filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.4));
}

.brand h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.brand p {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-section {
    padding: 20px 24px;
    border-bottom: 1px solid var(--card-border);
}

.sidebar-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Control Box (User & Sync actions) */
.control-box {
    background: rgba(30, 41, 59, 0.2);
}

.user-status-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    font-size: 18px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-role {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-primary);
    font-weight: 600;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.guest-card {
    font-size: 13px;
    color: var(--text-secondary);
    background: rgba(30, 41, 59, 0.25);
    border: 1px solid var(--card-border);
    padding: 14px;
    border-radius: 12px;
    line-height: 1.5;
}

.guest-card p {
    margin-bottom: 12px;
}

.control-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.logout-form {
    width: 100%;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-icon-wrapper {
    position: relative;
    width: 100%;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-icon-wrapper input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    background-color: rgba(17, 24, 39, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.3s;
}

.input-icon-wrapper input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Range Selector Buttons */
.range-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.btn-range {
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid var(--card-border);
    padding: 10px 4px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-range:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-range.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, #4f46e5 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: var(--color-danger);
    color: #fff;
}

.btn-accent {
    background: linear-gradient(135deg, var(--color-accent) 0%, #0891b2 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
    text-decoration: none;
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(6, 182, 212, 0.4);
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.sync-icon.loading {
    animation: spin 1s linear infinite;
}

/* Earthquake List Container */
.list-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-bottom: none;
}

.section-title-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-title-wrapper h3 {
    margin-bottom: 0;
}

.badge {
    background: rgba(6, 182, 212, 0.15);
    color: var(--color-accent);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 99px;
}

.eq-list {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Scrollbar for list container */
.eq-list::-webkit-scrollbar {
    width: 6px;
}

.eq-list::-webkit-scrollbar-track {
    background: transparent;
}

.eq-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.eq-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.list-placeholder {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 40px 0;
}

/* Earthquake Cards */
.eq-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.eq-card:hover {
    border-color: var(--card-hover-border);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.mag-badge {
    min-width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
    color: #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Color codes based on magnitude */
.mag-low {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.mag-med {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.mag-high {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.eq-info {
    flex-grow: 1;
    min-width: 0; /* allows text truncation */
}

.eq-region {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.eq-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: var(--text-secondary);
}

.eq-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.eq-meta i {
    width: 14px;
    color: var(--text-muted);
}

/* Main Map Area */
.map-area {
    flex-grow: 1;
    height: 100%;
    position: relative;
    background-color: #1a1a24;
}

#map {
    height: 100%;
    width: 100%;
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: var(--popup-bg) !important;
    color: var(--popup-text) !important;
    border: 1px solid var(--popup-border) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
    border-radius: 12px !important;
}

.leaflet-popup-content {
    margin: 16px 18px !important;
    font-family: 'Outfit', sans-serif !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
}

/* Modern popup formatting */
.popup-container {
    max-width: 260px;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
    margin-bottom: 8px;
    gap: 8px;
}

.popup-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}

.popup-mag {
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
}

.popup-row {
    margin-bottom: 6px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.popup-row:last-child {
    margin-bottom: 0;
}

.popup-row i {
    color: var(--color-accent);
    margin-top: 2px;
    width: 14px;
    text-align: center;
}

.popup-row span {
    color: var(--text-secondary);
}

.popup-row strong {
    color: var(--text-primary);
}

.map-legend {
    background: var(--bg-sidebar) !important;
    border: 1px solid var(--card-border) !important;
    padding: 14px 16px;
    border-radius: 12px;
    color: var(--text-primary) !important;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08) !important;
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
}

.map-legend h4 {
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--card-border) !important;
    padding-bottom: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Login Page Styling */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-main) 0%, rgba(99, 102, 241, 0.05) 100%);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, rgba(99, 102, 241, 0) 70%);
    top: -100px;
    right: -100px;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.06) 0%, rgba(6, 182, 212, 0) 70%);
    bottom: -100px;
    left: -100px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-sidebar);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.06);
    z-index: 10;
    transition: all 0.3s;
}

.dark-theme .login-card {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.brand-logo {
    width: 64px;
    height: 64px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px auto;
    color: var(--color-primary);
    font-size: 28px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.05);
}

.login-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.login-header p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.login-form .form-group label {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}

.login-form input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(99, 102, 241, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.3s;
}

.dark-theme .login-form input {
    background: rgba(0, 0, 0, 0.3);
}

.login-form input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.login-footer {
    margin-top: 24px;
    text-align: center;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.back-link:hover {
    color: var(--color-primary);
}
