/* style.css - Enhanced styles for Kadak Note */

/* ==========================================================================
   1. Root Variables & Base Styles
   ========================================================================== */
:root {
    --color-ink: #2b2d42; /* Darker, softer black */
    --color-muted: #8d99ae; /* Softer gray */
    --color-brand: #4a90e2; /* Muted blue */
    --color-brand-dark: #2b5d9a; /* Darker blue */
    --color-light-bg: #f8f9fa; /* Lighter background */
    --color-panel-bg: #ffffff;
    --color-panel-border: #e0e6ed; /* Softer border */
    --color-success: #5cb85c;
    --color-error: #d9534f;
    --color-warning: #f0ad4e;
    --color-info: #5bc0de;
    --color-cta: #ff7f50; /* Coral for CTA */

    --shadow-panel: 0 4px 12px rgba(0, 0, 0, 0.08); /* Softer, more diffused shadow */
    --shadow-modal: 0 12px 30px rgba(0, 0, 0, 0.15);
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    --border-radius: 0.75rem;
    --border-radius-small: 0.5rem;
    --transition: all 0.2s ease-in-out;
    --transition-slow: all 0.3s ease-in-out;
    --min-touch-target: 48px;
}

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

body {
    background-color: var(--color-light-bg);
    font-family: var(--font-primary);
    color: var(--color-ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   2. Typography
   ========================================================================== */
h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--color-brand-dark);
}

small {
    font-size: 0.85rem;
    color: var(--color-muted);
    display: block;
    margin-top: 0.25rem;
}

.section-description {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* ==========================================================================
   3. Layout Containers
   ========================================================================== */
.main-container {
    display: flex;
    flex-direction: column; /* Changed to column */
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    gap: 1rem;
    min-height: calc(100vh - 200px);
}

/* --- Header --- */
.app-header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--color-panel-bg) 0%, #f8faff 100%);
    border-bottom: 1px solid var(--color-panel-border);
}

.app-header__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 0.5rem;
}

.app-header__logo {
    height: 40px;
    width: auto;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.app-header__title {
    font-size: clamp(2.1rem, 5vw, 2.7rem);
    font-weight: 900;
    background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.app-header__subtitle {
    color: var(--color-muted);
    font-size: 1.06rem;
    margin: 0;
}

/* --- Control Panel --- */
.panel {
    background: var(--color-panel-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--color-panel-border);
    width: 100%; /* Changed to 100% */
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.panel__section {
    position: relative;
}

.panel__section h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel__section h3::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%);
    border-radius: 2px;
}

/* --- Map --- */
.map-container {
    flex: none; /* Changed to none */
    position: relative;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-panel);
    overflow: hidden;
    height: 50vh; /* Adjusted height */
    background: #eef2fc;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 300px;
}

#cobwebCanvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 401;
}

/* Map Legend */
.map-legend {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-small);
    padding: 0.75rem;
    box-shadow: var(--shadow-panel);
    z-index: 1000;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

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

.legend-icon {
    font-size: 1rem;
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--color-muted);
    font-size: 0.9rem;
    background: linear-gradient(135deg, var(--color-panel-bg) 0%, #f8faff 100%);
    border-top: 1px solid var(--color-panel-border);
}

.app-footer a {
    color: var(--color-brand);
    text-decoration: none;
    transition: var(--transition);
    padding: 0.5rem;
    border-radius: 0.25rem;
    margin: 0 0.25rem;
}

.app-footer a:hover {
    background: rgba(74, 144, 226, 0.1); /* Use new brand color */
    color: var(--color-brand-dark);
}

/* ==========================================================================
   4. Generic UI Components
   ========================================================================== */

/* --- Buttons --- */
.btn {
    position: relative;
    border: none;
    cursor: pointer;
    font-weight: 700;
    padding: 0.8rem 1.2rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    width: 100%;
    font-family: inherit;
    min-height: var(--min-touch-target);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    gap: 0.5rem;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.2); /* Use new brand color */
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn--primary {
    background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.25); /* Use new brand color */
}

.btn--secondary {
    background-color: #eef2fc;
    color: var(--color-ink);
    border: 1px solid #dbe5fa;
}

.btn--secondary:hover:not(:disabled) {
    background-color: #fff;
    border-color: var(--color-brand);
}

.btn--cta {
    background: linear-gradient(135deg, var(--color-cta) 0%, #e55a2b 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(255, 127, 80, 0.3); /* Use new CTA color */
    font-weight: 800;
    font-size: 1.1rem;
}

.btn--cta:hover:not(:disabled) {
    box-shadow: 0 8px 20px rgba(255, 127, 80, 0.4); /* Use new CTA color */
    transform: translateY(-3px);
}

.btn--loading {
    position: relative;
    color: transparent;
}

.btn--loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-size: 0.9rem;
    color: var(--color-ink);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.8rem;
    border-radius: var(--border-radius-small);
    border: 1px solid #e0e6ed; /* Softer border */
    background-color: #fdfdfe; /* Lighter background */
    font-size: 1rem;
    color: var(--color-ink);
    transition: var(--transition);
    font-family: inherit;
    min-height: var(--min-touch-target);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--color-brand);
    outline: 2px solid rgba(74, 144, 226, 0.2); /* Use new brand color */
    outline-offset: 2px;
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15); /* Use new brand color */
}

input:invalid {
    border-color: var(--color-error);
}

input:valid {
    border-color: var(--color-success);
}

.controls {
    display: flex;
    gap: 0.75rem;
}

/* --- Status Messages & Results --- */
.status-message {
    padding: 0.75rem;
    border-radius: var(--border-radius-small);
    margin-top: 1rem;
    font-size: 0.9rem;
    border-left: 4px solid var(--color-brand);
    background: rgba(74, 144, 226, 0.05); /* Use new brand color */
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.status-message--success {
    border-left-color: var(--color-success);
    background: rgba(92, 184, 92, 0.05); /* Use new success color */
    color: var(--color-success);
}

.status-message--error {
    border-left-color: var(--color-error);
    background: rgba(217, 83, 79, 0.05); /* Use new error color */
    color: var(--color-error);
}

.status-message--warning {
    border-left-color: var(--color-warning);
    background: rgba(240, 173, 78, 0.05); /* Use new warning color */
    color: #856404;
}

.status-message--info {
    border-left-color: var(--color-info);
    background: rgba(91, 192, 222, 0.05); /* Use new info color */
    color: var(--color-info);
}

.calculation-result {
    margin-top: 0.5rem;
    padding: 0.75rem;
    border-radius: var(--border-radius-small);
    font-weight: 600;
    color: var(--color-muted);
    border: 1px solid #e0e6ed; /* Softer border */
    background: var(--color-light-bg);
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.calculation-result.success {
    background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
    color: var(--color-success);
    border-color: #c3e6cb;
}

.calculation-result.error {
    background: rgba(217, 83, 79, 0.05); /* Use new error color */
    color: var(--color-error);
    border-color: var(--color-error);
}

/* ==========================================================================
   5. Specific Component Styles
   ========================================================================== */

/* --- Helper List --- */
.helper-count-inline {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.05) 0%, rgba(74, 144, 226, 0.1) 100%); /* Use new brand color */
    border-radius: var(--border-radius-small);
    color: var(--color-brand-dark);
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

.node-list {
    margin-top: 1rem;
    max-height: 40vh;
    min-height: 120px;
    overflow-y: auto;
    padding-right: 4px;
}

.node-list::-webkit-scrollbar {
    width: 6px;
}

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

.node-list::-webkit-scrollbar-thumb {
    background: var(--color-brand);
    border-radius: 3px;
}

.node-item {
    border: 1px solid var(--color-panel-border);
    border-radius: var(--border-radius);
    background: #fff;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    margin-bottom: 0.75rem;
}

.node-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15); /* Use new brand color */
    border-color: var(--color-brand);
}

.node-item__info {
    flex: 1;
}

.node-item__details {
    font-size: 0.9rem;
    color: var(--color-muted);
}

.node-item__btn {
    flex-shrink: 0;
    margin-left: 1rem;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
}

/* --- Drawer --- */
.drawer {
    position: fixed;
    top: 0;
    right: -400px; /* Start off-screen */
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: #fff;
    box-shadow: var(--shadow-modal);
    z-index: 2000;
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

.drawer[aria-hidden="false"] {
    transform: translateX(-400px);
}

.drawer__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-panel-border);
}

.drawer__close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-muted);
}

.drawer__content {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.step__number {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--color-brand);
    background: rgba(74, 144, 226, 0.1); /* Use new brand color */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step__content h4 {
    margin-bottom: 0.25rem;
}

/* --- Floating Action Button (FAB) --- */
.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--color-brand);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    box-shadow: 0 8px 24px rgba(74, 144, 226, 0.3); /* Use new brand color */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-slow);
    z-index: 1500;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(74, 144, 226, 0.4); /* Use new brand color */
}

.fab__nugget {
    font-size: 1.5rem;
    font-weight: 700;
}

.fab__hint {
    position: absolute;
    right: 120%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-brand-dark);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-small);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.fab:hover .fab__hint {
    opacity: 1;
    visibility: visible;
}

/* --- UPI Payment Box --- */
.upi-payment-box {
    padding: 1rem;
    margin-top: 1rem;
    border: 1px dashed var(--color-brand);
    border-radius: var(--border-radius-small);
    background: rgba(74, 144, 226, 0.05); /* Use new brand color */
}

.upi-payment-box__details {
    margin: 0.5rem 0;
    font-weight: 600;
}

/* ==========================================================================
   6. Media Queries for Responsiveness
   ========================================================================== */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }

    .panel {
        width: 100%;
        max-height: none;
        overflow-y: visible;
    }

    .map-container {
        height: 50vh;
    }

    .legend-toggle {
        display: block; /* Show toggle on mobile */
    }

    .map-legend {
        display: none; /* Hide legend by default on mobile */
    }

    .map-legend.open {
        display: block;
    }

    .drawer {
        max-width: 100%;
        right: -100%;
    }

    .drawer[aria-hidden="false"] {
        transform: translateX(-100%);
    }
}
.spinner {
  margin-top: 10px;
  font-size: 14px;
  color: #555;
  font-style: italic;
}

