/* CSS Design System for Getnomik Legal News Aggregator */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* Color Palette (HSL Tailored) */
    --bg-dark: hsl(222, 47%, 8%);
    --bg-panel: hsla(223, 47%, 11%, 0.85);
    --bg-card: hsla(223, 47%, 14%, 0.6);
    --border-color: hsla(217, 30%, 20%, 0.5);
    --border-glow: hsla(217, 30%, 30%, 0.8);
    
    --text-primary: hsl(210, 40%, 96%);
    --text-secondary: hsl(215, 20%, 75%);
    --text-muted: hsl(215, 15%, 55%);
    
    /* Accents */
    --accent-blue: hsl(217, 91%, 60%);
    --accent-blue-glow: hsla(217, 91%, 60%, 0.15);
    --accent-emerald: hsl(150, 84%, 43%);
    --accent-emerald-glow: hsla(150, 84%, 43%, 0.15);
    --accent-coral: hsl(346, 84%, 61%);
    --accent-coral-glow: hsla(346, 84%, 61%, 0.15);
    --accent-amber: hsl(38, 92%, 50%);
    --accent-amber-glow: hsla(38, 92%, 50%, 0.15);
    
    /* Categories */
    --cat-gst: hsl(263, 70%, 55%);
    --cat-court: hsl(200, 85%, 50%);
    --cat-company: hsl(330, 80%, 50%);
    --cat-rbi: hsl(160, 75%, 40%);
    --cat-tax: hsl(25, 90%, 50%);
    --cat-govt: hsl(45, 90%, 45%);
    --cat-general: hsl(210, 15%, 50%);

    /* Fonts & Sizes */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Shadow */
    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-glow: 0 0 20px 2px hsla(217, 91%, 60%, 0.1);
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 20%, hsla(220, 80%, 15%, 0.3) 0px, transparent 50%),
        radial-gradient(at 90% 80%, hsla(270, 70%, 15%, 0.25) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Layout Structure */
#app-layout {
    display: flex;
    width: 100%;
}

/* Sidebar Navigation */
sidebar {
    width: 280px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
}

.brand-section {
    padding: 30px 24px;
    border-bottom: 1px solid var(--border-color);
}

.brand-section h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-section h1 span {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: hsla(217, 91%, 60%, 0.15);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid hsla(217, 91%, 60%, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-links {
    list-style: none;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background-color: hsla(217, 91%, 60%, 0.08);
    border-color: hsla(217, 91%, 60%, 0.2);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.nav-item:hover svg {
    transform: translateX(3px);
}

.sidebar-footer {
    margin-top: auto;
    padding: 24px;
    border-top: 1px solid var(--border-color);
}

.sync-status-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 12px;
    font-size: 0.85rem;
}

.sync-status-card .status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
}

.pulse-indicator {
    width: 8px;
    height: 8px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-emerald);
}

.pulse-indicator.syncing {
    background-color: var(--accent-amber);
    box-shadow: 0 0 8px var(--accent-amber);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.85); opacity: 0.5; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(0.85); opacity: 0.5; }
}

/* Main Workspace */
main {
    flex-grow: 1;
    margin-left: 280px;
    padding: 40px;
    min-height: 100vh;
}

/* Page Containers */
.page {
    display: none;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.page.active {
    display: block;
}

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

/* Stats Panel Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-soft);
    transition: border-color 0.3s ease, transform 0.3s ease;
}

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

.stat-details h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.stat-details .value {
    font-size: 1.8rem;
    font-family: var(--font-heading);
    font-weight: 700;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.total { background: hsla(217, 91%, 60%, 0.1); color: var(--accent-blue); }
.stat-icon.uncovered { background: hsla(150, 84%, 43%, 0.1); color: var(--accent-emerald); }
.stat-icon.priority { background: hsla(346, 84%, 61%, 0.1); color: var(--accent-coral); }

/* Control & Filter Panel */
.controls-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-soft);
}

.search-box {
    position: relative;
    flex-grow: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px 12px 42px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.search-box input:focus {
    border-color: var(--accent-blue);
}

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.filter-select {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    min-width: 150px;
    transition: border-color 0.3s ease;
}

.filter-select:focus {
    border-color: var(--accent-blue);
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    padding: 8px 12px;
}

.checkbox-container input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.btn {
    background-color: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 14px 0 hsla(217, 91%, 60%, 0.3);
}

.btn:hover {
    background-color: hsl(217, 91%, 65%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 hsla(217, 91%, 60%, 0.4);
}

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

.btn-secondary {
    background-color: hsla(217, 91%, 60%, 0.1);
    color: var(--accent-blue);
    border: 1px solid hsla(217, 91%, 60%, 0.3);
    box-shadow: none;
}

.btn-secondary:hover {
    background-color: hsla(217, 91%, 60%, 0.18);
    box-shadow: none;
}

.btn-danger {
    background-color: hsla(346, 84%, 61%, 0.1);
    color: var(--accent-coral);
    border: 1px solid hsla(346, 84%, 61%, 0.3);
    box-shadow: none;
}

.btn-danger:hover {
    background-color: hsla(346, 84%, 61%, 0.2);
    box-shadow: none;
}

/* News List Grid */
.news-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.news-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
}

.news-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--accent-blue);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.news-card:hover {
    border-color: var(--border-glow);
    transform: translateY(-2px) scale(1.005);
}

.news-card:hover::before {
    opacity: 1;
}

.news-card.covered {
    opacity: 0.65;
}

.news-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.news-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.meta-source {
    font-weight: 600;
    color: var(--text-secondary);
}

.meta-bullet {
    width: 4px;
    height: 4px;
    background-color: var(--text-muted);
    border-radius: 50%;
}

.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}

/* Category Badge Styling */
.badge-gst { background: hsla(263, 70%, 55%, 0.15); color: var(--cat-gst); border-color: hsla(263, 70%, 55%, 0.3); }
.badge-court { background: hsla(200, 85%, 50%, 0.15); color: var(--cat-court); border-color: hsla(200, 85%, 50%, 0.3); }
.badge-company { background: hsla(330, 80%, 50%, 0.15); color: var(--cat-company); border-color: hsla(330, 80%, 50%, 0.3); }
.badge-rbi { background: hsla(160, 75%, 40%, 0.15); color: var(--cat-rbi); border-color: hsla(160, 75%, 40%, 0.3); }
.badge-tax { background: hsla(25, 90%, 50%, 0.15); color: var(--cat-tax); border-color: hsla(25, 90%, 50%, 0.3); }
.badge-govt { background: hsla(45, 90%, 45%, 0.15); color: var(--cat-govt); border-color: hsla(45, 90%, 45%, 0.3); }
.badge-general { background: hsla(210, 15%, 50%, 0.15); color: var(--text-secondary); border-color: hsla(210, 15%, 50%, 0.3); }

/* Priority Badge Styling */
.badge-priority-high {
    background: var(--accent-coral-glow);
    color: var(--accent-coral);
    border-color: hsla(346, 84%, 61%, 0.3);
    box-shadow: 0 0 10px 0 hsla(346, 84%, 61%, 0.1);
    animation: flash-badge 2s infinite alternate;
}
.badge-priority-medium { background: var(--accent-amber-glow); color: var(--accent-amber); border-color: hsla(38, 92%, 50%, 0.3); }
.badge-priority-low { background: hsla(215, 15%, 55%, 0.1); color: var(--text-muted); border-color: hsla(215, 15%, 55%, 0.2); }

@keyframes flash-badge {
    0% { border-color: hsla(346, 84%, 61%, 0.2); }
    100% { border-color: hsla(346, 84%, 61%, 0.6); }
}

.news-card-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
}

.news-card-summary {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.news-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: 4px;
}

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

/* Slide-out Drawer Panel */
.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 650px;
    height: 100vh;
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.drawer-backdrop.open .drawer {
    transform: translateX(0);
}

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

.drawer-header h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
}

.drawer-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.drawer-close:hover {
    background-color: hsla(0, 0%, 100%, 0.05);
    color: var(--text-primary);
}

.drawer-content {
    padding: 30px;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.drawer-meta-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.drawer-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-meta-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.drawer-meta-value {
    font-size: 0.9rem;
    font-weight: 600;
}

.drawer-article {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.drawer-article-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.4;
}

.drawer-article-summary {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Draft Generation Area */
.draft-section {
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.draft-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.draft-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
}

.draft-box {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    color: var(--text-secondary);
}

.draft-box.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-style: italic;
}

/* Sources Management Table */
.sources-table-container {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    margin-bottom: 30px;
}

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

.sources-table th, .sources-table td {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
}

.sources-table th {
    background-color: hsla(223, 47%, 10%, 0.5);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.sources-table tr:hover td {
    background-color: hsla(0, 0%, 100%, 0.01);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: hsla(0, 0%, 100%, 0.1);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-emerald-glow);
    border-color: var(--accent-emerald);
}

input:checked + .slider:before {
    transform: translateX(20px);
    background-color: var(--accent-emerald);
}

/* Add Source Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 100%;
    max-width: 550px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-backdrop.open .modal {
    transform: translateY(0);
}

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

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-body {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-control {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    border-color: var(--accent-blue);
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Helper details */
.helper-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Spinner & Loading */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
    color: var(--text-muted);
    font-style: italic;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.sync-rotate {
    animation: spin 1.2s linear infinite;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-blue);
    padding: 16px 24px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left-color: var(--accent-emerald); }
.toast.error { border-left-color: var(--accent-coral); }
.toast.warning { border-left-color: var(--accent-amber); }

/* Responsive adjustments */
@media(max-width: 900px) {
    sidebar {
        width: 70px;
        padding: 10px 0;
    }
    .brand-section h1, .brand-section span, .nav-item span, .sync-status-card, .sidebar-footer {
        display: none;
    }
    .nav-links {
        padding: 20px 8px;
    }
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    main {
        margin-left: 70px;
        padding: 24px;
    }
}
