/* --- Material Design 3 Inspired Redesign --- */
:root {
    /* M3 Color Palette */
    --md-sys-color-primary: #4f46e5; /* Indigo 600 */
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #e0e7ff; /* Indigo 100 */
    --md-sys-color-on-primary-container: #312e81; /* Indigo 900 */
    --md-sys-color-secondary: #6366f1; /* Indigo 500 */
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-surface: #f8fafc; /* Slate 50 */
    --md-sys-color-surface-container: #ffffff;
    --md-sys-color-on-surface: #1f2937; /* Gray 800 */
    --md-sys-color-on-surface-variant: #4b5563; /* Gray 600 */
    --md-sys-color-outline: #e5e7eb; /* Gray 200 */
    --md-sys-color-error: #ef4444; /* Red 500 */
    --md-sys-color-success: #10b981; /* Green 600 */
    --md-sys-color-success-text: #064e3b;
    --md-sys-color-error-text: #991b1b;
    --md-sys-color-shadow: rgba(0, 0, 0, 0.1);

    /* Elevation */
    --md-sys-elevation-level-1: 0 1px 3px 0 var(--md-sys-color-shadow), 0 1px 2px -1px var(--md-sys-color-shadow);
    --md-sys-elevation-level-2: 0 4px 6px -1px var(--md-sys-color-shadow), 0 2px 4px -2px var(--md-sys-color-shadow);
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
}

/* --- Base Components --- */
.card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: 1rem;
    border: 1px solid var(--md-sys-color-outline);
    box-shadow: var(--md-sys-elevation-level-1);
}

#mainAppSection, #loginSection {
    background-color: var(--md-sys-color-surface-container);
    border-radius: 1.5rem; /* Large radius for main container */
    box-shadow: var(--md-sys-elevation-level-2);
}

h1,h2,h3,h4,h5,h6 {
     color: var(--md-sys-color-on-surface);
}

button, .button {
    border-radius: 9999px;
    font-weight: 500;
    padding: 0.625rem 1.5rem;
    transition: all 0.2s ease-in-out;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border:none;
}
button:hover, .button:hover {
    box-shadow: var(--md-sys-elevation-level-2);
    transform: translateY(-1px);
}
button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

#loginShoonyaBtn, #fetchAISignalBtn {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}
#loginShoonyaBtn:hover, #fetchAISignalBtn:hover {
     background-color: #4338ca; /* Darker Indigo */
}

#manualBuyBtn { background-color: var(--md-sys-color-success); color: var(--md-sys-color-on-primary); }
#manualSellBtn { background-color: var(--md-sys-color-error); color: var(--md-sys-color-on-primary); }
#logoutBtn { background-color: var(--md-sys-color-error); color: var(--md-sys-color-on-primary); }

input, select {
    border-radius: 0.5rem;
    border: 1px solid var(--md-sys-color-outline);
    background-color: #ffffff;
    transition: all 0.2s;
    padding: 0.5rem;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 3px var(--md-sys-color-primary-container);
}

.status-box {
     background-color: #ffffff;
     border: 1px solid var(--md-sys-color-outline);
     border-radius: 1rem;
     padding: 1rem;
}

.loading-spinner { border: 4px solid #f3f3f3; border-top: 4px solid var(--md-sys-color-primary); border-radius: 50%; width: 30px; height: 30px; animation: spin 1s linear infinite; display: none; margin: 20px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Tabs --- */
.tab-button {
    color: var(--md-sys-color-on-surface-variant);
    border-bottom: 2px solid transparent;
    padding-bottom: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
}
.tab-button.active {
    color: var(--md-sys-color-primary);
    border-bottom-color: var(--md-sys-color-primary);
}

/* --- Watchlist --- */
#watchlistContainer { background-color: var(--md-sys-color-surface-container); }
.watchlist-row { transition: background-color 0.2s; border-bottom: 1px solid var(--md-sys-color-outline); }
.watchlist-row:hover { background-color: var(--md-sys-color-primary-container); }
.watchlist-row.primary { background-color: var(--md-sys-color-primary-container) !important; font-weight: bold; border-left: 4px solid var(--md-sys-color-primary); }
.remove-watchlist-btn { background-color: #fee2e2; color: #b91c1c; border: none; border-radius: 50%; width: 24px; height: 24px; font-size: 1rem; line-height: 24px; text-align: center; cursor: pointer; font-weight: bold; transition: all 0.2s; }
.remove-watchlist-btn:hover { background-color: var(--md-sys-color-error); color: white; transform: scale(1.1); }

/* --- Redesigned AI Analysis Card --- */
.signal-card {
    background: linear-gradient(145deg, var(--md-sys-color-surface-container), #f9fafb);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: var(--md-sys-elevation-level-1);
    transition: all 0.3s ease-in-out;
    border-left: 6px solid;
    position: relative;
    overflow: hidden;
}
.signal-card-buy { border-color: var(--md-sys-color-success); }
.signal-card-sell { border-color: var(--md-sys-color-error); }
.signal-card-hold { border-color: var(--md-sys-color-on-surface-variant); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; }
.card-title { font-size: 1.1rem; font-weight: 500; color: var(--md-sys-color-on-surface); }
.card-ltp { font-size: 0.875rem; color: var(--md-sys-color-on-surface-variant); font-weight: 500; }
.card-action { font-size: 2rem; font-weight: 700; text-transform: uppercase; margin-bottom: 0.75rem; }
.text-action-buy { color: var(--md-sys-color-success); }
.text-action-sell { color: var(--md-sys-color-error); }
.text-action-hold { color: var(--md-sys-color-on-surface-variant); }
.card-reason { font-size: 0.8rem; color: var(--md-sys-color-on-surface-variant); min-height: 30px; font-style: italic; }
.score-bar-container { width: 100%; background-color: var(--md-sys-color-outline); border-radius: 9999px; height: 8px; overflow: hidden; margin-top: 1rem; }
.score-bar { height: 100%; border-radius: 9999px; transition: width 0.5s ease-in-out; }
.score-bar-buy { background: linear-gradient(90deg, #10b981, #6ee7b7); }
.score-bar-hold { background: linear-gradient(90deg, #6b7280, #9ca3af); }
.signal-checklist { font-size: 0.8rem; margin-top: 1rem; border-top: 1px solid var(--md-sys-color-outline); padding-top: 0.75rem; }
.signal-checklist-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.checklist-label { font-weight: 500; color: #374151; }
.checklist-status.status-true { color: var(--md-sys-color-success); font-weight: 700;}
.checklist-status.status-false { color: var(--md-sys-color-error); font-weight: 700;}
.checklist-current-value { font-weight: 600; }
.checklist-required-value { color: #6b7280; margin-left: 4px; font-style: italic; }

/* --- Settings Page --- */
.settings-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}
.settings-group { background-color: var(--md-sys-color-surface-container); border: 1px solid var(--md-sys-color-outline); border-radius: 1rem; padding: 1.5rem; }
.settings-group h3 { font-size: 1.1rem; font-weight: 700; color: var(--md-sys-color-primary); border-bottom: 1px solid var(--md-sys-color-outline); padding-bottom: 0.5rem; margin-bottom: 1rem; }
.setting-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; }
.setting-item label { font-size: 0.875rem; font-weight: 400; color: var(--md-sys-color-on-surface-variant); flex-shrink: 0; margin-right: 1rem; }
.setting-item input[type="number"], .setting-item input[type="checkbox"] { flex-shrink: 0; }
.setting-item input[type="number"] { width: 80px; text-align: right; }

/* --- Other --- */
.log-content { font-family: 'Courier New', Courier, monospace; background-color: #f8f9fa; border-radius: 0.5rem; }
.positive-change, .positive-pnl-text { color: var(--md-sys-color-success-text); font-weight: 500;}
.negative-change, .negative-pnl-text { color: var(--md-sys-color-error-text); font-weight: 500;}
.status-dot { height: 10px; width: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.status-dot.connected { background-color: var(--md-sys-color-success); }
.status-dot.disconnected { background-color: var(--md-sys-color-error); }
