/* 
    GreenRoute Core Stylesheet
    Consolidated global styles, variables, and components.
*/

:root {
    --primary-color: #10B981;
    --primary-dark: #059669;
    --bg-base: #0B0F19;
    --bg-surface: #131A2A;
    --bg-surface-hover: #1E293B;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border-color: #334155;
    --error-color: #EF4444;
    --sidebar-width: 260px;
    --panel-bg: rgba(19, 26, 42, 0.85);
    --panel-border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(0, 0, 0, 0.3);
}

body.theme-light {
    --primary-color: #059669;
    --primary-dark: #047857;
    --bg-base: #F1F5F9;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #E2E8F0;
    --text-main: #0F172A;
    --text-muted: #475569;
    --border-color: #CBD5E1;
    --panel-bg: rgba(255, 255, 255, 0.85);
    --panel-border: rgba(0, 0, 0, 0.1);
    --input-bg: rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =========================================================
   1. Shared UI Components
   ========================================================= */

/* Ambient subtle background glow */
.ambient-glow {
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, rgba(11, 15, 25, 0) 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
}

.msg-item {
    padding: 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
}

.msg-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.msg-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: #FCA5A5;
    border: 1px solid var(--error-color);
}

.error-message {
    background-color: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--error-color);
    color: #FCA5A5;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* =========================================================
   2. Login Portal Styles
   ========================================================= */

/* Use a specialized body class if needed for login specifically */
.login-body {
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.login-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    z-index: 10;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    animation: cardAppear 0.4s ease-out forwards;
}

@keyframes cardAppear {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.logo-container {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background-color: #129C69;
    margin-bottom: 16px;
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3);
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
    background: linear-gradient(to right, #fff, var(--text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 14px;
}

.form-input {
    width: 100%;
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px 12px 42px;
    font-size: 14px;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.btn-submit {
    width: 100%;
    background: linear-gradient(to right, var(--primary-color), var(--primary-dark));
    color: #0B0F19;
    border: none;
    border-radius: 8px;
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.1s ease;
    margin-top: 12px;
}

.btn-submit:hover { opacity: 0.95; }
.btn-submit:active { transform: scale(0.98); }

/* =========================================================
   3. Admin Dashboard Styles
   ========================================================= */

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    font-weight: bold;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, #94A3B8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.sidebar-link:hover, .sidebar-link.active {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
}

.sidebar-link.active {
    border-left: 4px solid var(--primary-color);
}

.sidebar-link i {
    font-size: 16px;
    width: 20px;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.top-navbar {
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #0B0F19;
}

.content-container {
    padding: 32px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* Dashboard Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.stat-card-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
}

.stat-icon {
    position: absolute;
    right: 20px;
    top: 24px;
    font-size: 24px;
    color: rgba(16, 185, 129, 0.2);
}

/* Table Section */
.table-section {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-title {
    font-size: 16px;
    font-weight: 600;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 14px 24px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.2);
}

.data-table td {
    padding: 16px 24px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--primary-color);
}

/* Responsive Overrides */
@media (max-width: 1024px) {
    .sidebar { width: 70px; }
    .sidebar-title, .sidebar-link span { display: none; }
    .main-wrapper { margin-left: 70px; }
}

/* =========================================================
   4. Public Client Dashboard Styles
   ========================================================= */

.client-dashboard-body {
    overflow: hidden; /* Prevent scrolling, map takes full screen */
}

.client-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
}

.map-container {
    width: 100%;
    height: 100%;
    z-index: 1; /* Leaflet map goes behind */
}

/* Floating Glassmorphism Panel */
.floating-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 360px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--panel-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    
    border-radius: 16px;
    padding: 24px;
    z-index: 1000; /* Over the Leaflet map controls */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 16px;
}

.logo-icon-small {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background-color: #129C69;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.form-group-modern {
    position: relative;
    overflow: visible;
}

.form-group-modern label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-modern {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 0 12px;
    gap: 10px;
    position: relative;
    width: 100%;
}

.input-modern input {
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 12px 0;
    width: 100%;
    font-size: 13px;
    outline: none;
}

.input-modern input::placeholder {
    color: var(--text-muted);
}

/* Location suggestions dropdown */
.location-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1001;
    z-index: 1001;
    margin-top: -1px;
    padding: 0;
    display: block;
    min-width: 100%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-main);
    transition: background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid var(--border-color);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover:not(.disabled) {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary-color);
}

.suggestion-item.disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    background: transparent;
}

.btn-calculate {
    width: 100%;
    background: linear-gradient(to right, var(--primary-color), var(--primary-dark));
    color: #0B0F19;
    border: none;
    border-radius: 8px;
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-calculate:active {
    transform: scale(0.98);
}

.btn-calculate:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Metrics Card */
.eco-metrics-card {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    padding: 16px;
    transition: opacity 0.3s ease;
}

.eco-metrics-card.hidden {
    display: none;
}

.eco-metrics-card h3 {
    font-size: 13px;
    color: var(--primary-color);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.metric {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 11px;
    color: var(--text-muted);
}

.metric-value {
    font-size: 18px;
    color: var(--text-main);
}

.metric-value.success {
    color: var(--primary-color);
}

.eco-impact {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--primary-color);
    background: rgba(16, 185, 129, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
}

.panel-footer {
    text-align: center;
    border-top: 1px solid var(--panel-border);
    padding-top: 16px;
    margin-top: 4px;
}

.panel-footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    transition: color 0.2s;
}

.panel-footer a:hover {
    color: var(--text-main);
}
