/* ============================================
   Medi Launch Internal Tools — Sidebar Layout
   Dark theme inspired by Agency Bot UI
   ============================================ */

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

:root {
    --sidebar-width: 240px;
    --bg-dark: #0b0f1a;
    --bg-sidebar: #0f1322;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
    --bg-sidebar-active: rgba(74, 158, 255, 0.12);
    --bg-main: #0b0f1a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-input: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-active: rgba(74, 158, 255, 0.4);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.65);
    --text-muted: rgba(255, 255, 255, 0.4);
    --accent: #4a9eff;
    --accent-2: #6366f1;
    --accent-glow: rgba(74, 158, 255, 0.15);
    --gradient-accent: linear-gradient(135deg, #4a9eff, #6366f1);
    --gradient-card: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.4);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    overflow: hidden;
}

[hidden] { display: none !important; }

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    gap: 6px;
}

.logo-medi {
    color: var(--text-primary);
}

.logo-launch {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-section {
    flex: 1;
    padding: 16px 0;
}

.sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 20px 12px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.sidebar-nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

.sidebar-nav-item.active {
    background: var(--bg-sidebar-active);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ============================================
   Main Content Area
   ============================================ */
.main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.main-inner {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 32px;
}

/* ============================================
   Tool Panels
   ============================================ */
.tool-panel {
    display: none;
    height: 100%;
}

.tool-panel.active {
    display: flex;
    flex-direction: column;
}

/* ============================================
   Tool Header (centered, like Agency Bot)
   ============================================ */
.tool-hero {
    text-align: center;
    margin-bottom: 36px;
}

.tool-hero-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 16px;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.tool-hero-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.tool-hero-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* ============================================
   Form Inputs
   ============================================ */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-primary);
}

.form-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 11px 14px;
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.form-textarea {
    min-height: 220px;
    resize: vertical;
    line-height: 1.7;
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.char-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--gradient-accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 16px;
    height: 16px;
}

/* ============================================
   Output Section
   ============================================ */
.output-section {
    display: none;
    margin-top: 8px;
}

.output-section.visible {
    display: block;
}

.output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.output-title {
    font-size: 1rem;
    font-weight: 600;
}

.output-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   Notes Output (formatted text display)
   ============================================ */
.notes-output {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 28px 32px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-secondary);
    max-height: 60vh;
    overflow-y: auto;
}

.notes-section-header {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    padding: 4px 0;
    letter-spacing: 0.02em;
}

.notes-bullet {
    color: var(--text-secondary);
    padding: 2px 0;
}

.notes-line {
    padding: 2px 0;
}

.notes-spacer {
    height: 8px;
}

.notes-status {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.notes-status-resolved {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
}

.notes-status-partial {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.notes-status-open {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}

/* ============================================
   Loading State
   ============================================ */
.loading-state {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px 0;
    color: var(--text-muted);
}

.loading-state.visible {
    display: flex;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 0.9rem;
}

.loading-subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================
   Error State
   ============================================ */
.error-state {
    display: none;
    text-align: center;
    padding: 40px 0;
    color: var(--danger);
}

.error-state.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.error-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 500px;
}

/* ============================================
   Toast Notification
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px 20px;
    font-size: 0.875rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    border-color: rgba(52, 211, 153, 0.3);
}

/* ============================================
   Custom Date Picker
   ============================================ */
.dp-wrapper {
    position: relative;
    width: 100%;
}

.dp-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    white-space: nowrap;
}

.dp-trigger-icon {
    color: var(--text-muted);
    display: flex;
    flex-shrink: 0;
}

.dp-trigger-text {
    color: var(--text-primary);
}

.dp-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 280px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
}

.dp-dropdown.dp-open {
    display: block;
}

.dp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.dp-month-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dp-nav-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
    font-family: inherit;
}

.dp-nav-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

.dp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    margin-bottom: 6px;
}

.dp-weekdays span {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-align: center;
    padding: 4px 0;
}

.dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.dp-day {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    margin: 0 auto;
}

.dp-day:hover:not(.dp-day-disabled):not(.dp-day-selected) {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

.dp-day-selected {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.dp-day-today {
    border: 1px solid var(--accent);
    color: var(--accent);
}

.dp-day-disabled {
    cursor: default;
    opacity: 0;
}

/* ============================================
   Settings / Prompt Editor
   ============================================ */
.settings-prompt-section {
    margin-bottom: 32px;
}

.settings-prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.settings-prompt-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-prompt-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 4px;
    background: rgba(74, 158, 255, 0.12);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.settings-prompt-textarea {
    min-height: 400px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    tab-size: 2;
}

.settings-save-status {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-left: 12px;
}

.settings-save-status.saved {
    color: var(--success);
}

/* ============================================
   Grade Cards (Intro Call Grading)
   ============================================ */
.grade-overview {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.grade-overview-score {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 700;
}

.grade-overview-score.grade-green { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.grade-overview-score.grade-yellow { background: rgba(234, 179, 8, 0.12); color: #eab308; }
.grade-overview-score.grade-red { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

.grade-overview-number {
    font-size: 2rem;
    line-height: 1;
}

.grade-overview-divider {
    font-size: 1.2rem;
    opacity: 0.5;
}

.grade-overview-total {
    font-size: 1.2rem;
    opacity: 0.7;
}

.grade-overview-meta {
    flex: 1;
}

.grade-overview-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.grade-overview-type {
    font-size: 0.82rem;
    color: var(--text-primary);
}

.grade-overview-pct {
    font-size: 1.8rem;
    font-weight: 700;
}

.grade-overview-pct.grade-green { color: #22c55e; }
.grade-overview-pct.grade-yellow { color: #eab308; }
.grade-overview-pct.grade-red { color: #ef4444; }

.grade-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.grade-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border-left: 4px solid transparent;
    transition: var(--transition);
}

.grade-card.grade-green {
    border-left-color: #22c55e;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.06) 0%, var(--bg-card) 60%);
}

.grade-card.grade-yellow {
    border-left-color: #eab308;
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.06) 0%, var(--bg-card) 60%);
}

.grade-card.grade-red {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.06) 0%, var(--bg-card) 60%);
}

.grade-card-full {
    margin-bottom: 12px;
}

.grade-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.grade-card-title-block {
    flex: 1;
    min-width: 0;
}

.grade-card-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.grade-card-desc {
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.grade-card-score-block {
    text-align: right;
    flex-shrink: 0;
    margin-left: 20px;
}

.grade-card-score {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 2px;
    font-weight: 700;
}

.grade-green .grade-card-score { color: #22c55e; }
.grade-yellow .grade-card-score { color: #eab308; }
.grade-red .grade-card-score { color: #ef4444; }

.grade-card-num {
    font-size: 1.3rem;
}

.grade-card-slash {
    font-size: 0.82rem;
    opacity: 0.5;
}

.grade-card-max {
    font-size: 0.88rem;
    opacity: 0.7;
}

.grade-card-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 2px;
}

.grade-green .grade-card-label { color: #22c55e; }
.grade-yellow .grade-card-label { color: #eab308; }
.grade-red .grade-card-label { color: #ef4444; }

.grade-card-feedback {
    font-size: 0.84rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.grade-card-bullets {
    list-style: none;
    padding: 0;
    margin: 0;
}

.grade-card-bullets li {
    font-size: 0.84rem;
    line-height: 1.6;
    color: var(--text-primary);
    padding: 4px 0 4px 16px;
    position: relative;
}

.grade-card-bullets li::before {
    content: '\2022';
    position: absolute;
    left: 0;
    color: var(--text-muted);
}

.grade-section-block {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.grade-section-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.grade-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.grade-list li {
    font-size: 0.84rem;
    line-height: 1.6;
    color: var(--text-secondary);
    padding: 6px 0 6px 16px;
    position: relative;
}

.grade-list li::before {
    content: '\2022';
    position: absolute;
    left: 0;
    color: var(--text-muted);
}

.grade-flags {
    border-left: 3px solid #ef4444;
}

.grade-misses {
    border-left: 3px solid #ef4444;
}

.grade-highlights {
    border-left: 3px solid #22c55e;
}

.grade-coaching {
    border-left: 3px solid var(--accent);
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

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

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-logo,
    .sidebar-section-label,
    .sidebar-nav-label,
    .sidebar-user-name {
        display: none;
    }

    .sidebar-header {
        padding: 16px 14px;
        display: flex;
        justify-content: center;
    }

    .sidebar-nav-item {
        justify-content: center;
        padding: 10px;
    }

    .sidebar-nav-icon {
        margin: 0;
    }

    .sidebar-user {
        justify-content: center;
    }

    .main-inner {
        padding: 24px 16px;
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .output-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}
