/* Google Fonts: Inter & Outfit */
@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 {
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Sleek Dark Mode HSL Colors */
    --bg-main: 222 47% 7%;      /* #0b0f19 */
    --bg-card: 224 71% 4%;      /* #030712 */
    --border-color: 217 19% 27%;
    
    --primary: 199 89% 48%;     /* Cyan #0ea5e9 */
    --primary-glow: 199 89% 48% / 0.15;
    --secondary: 263 70% 50%;   /* Purple */
    
    --success: 142 71% 45%;     /* Emerald */
    --warning: 38 92% 50%;      /* Amber */
    --danger: 350 89% 60%;      /* Rose */
    
    --text-primary: 210 40% 98%;   /* Slate 50 */
    --text-secondary: 215 20% 65%; /* Slate 400 */
    --text-muted: 215 16% 47%;     /* Slate 500 */
    
    --glass-bg: rgba(17, 24, 39, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-glow: rgba(14, 165, 233, 0.05);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: hsl(var(--bg-main));
    background-image: 
        radial-gradient(at 0% 0%, rgba(30, 58, 138, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
        radial-gradient(at 50% 0%, rgba(14, 165, 233, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    color: hsl(var(--text-primary));
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* App Layout */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header design */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--secondary)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #ffffff, hsl(var(--text-secondary)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: hsl(var(--text-secondary));
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: var(--transition-smooth);
}

.nav-link:hover, .nav-link.active {
    color: hsl(var(--text-primary));
    background: rgba(255, 255, 255, 0.05);
}

/* Page views */
.view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.view.active {
    display: block;
}

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

/* Homepage / Tool Directory list */
.home-intro {
    text-align: center;
    max-width: 800px;
    margin: 4rem auto;
}

.home-intro h1 {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #ffffff 50%, hsl(var(--primary)) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.home-intro p {
    color: hsl(var(--text-secondary));
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

/* Premium Card */
.tool-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    border-radius: 1.25rem;
    padding: 2rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(124, 58, 237, 0.1));
    opacity: 0;
    transition: var(--transition-smooth);
    z-index: 0;
}

.tool-card:hover {
    transform: translateY(-5px);
    border-color: rgba(14, 165, 233, 0.3);
    box-shadow: 0 10px 30px -10px rgba(14, 165, 233, 0.2);
}

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

.tool-card-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tool-icon {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    display: inline-block;
}

.tool-title {
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
    color: #ffffff;
}

.tool-desc {
    color: hsl(var(--text-secondary));
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.tool-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: hsl(var(--primary));
    font-size: 0.95rem;
}

.tool-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tool-card.disabled:hover {
    transform: none;
    border-color: var(--glass-border);
    box-shadow: none;
}

.tool-card.disabled:hover::before {
    opacity: 0;
}

.tag-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    color: hsl(var(--text-secondary));
}

/* General Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--secondary)));
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--glass-border);
    color: hsl(var(--text-primary));
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

/* Tool Workspace Layout */
.workspace-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 992px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

/* Glass Panel Component */
.panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    border-radius: 1.25rem;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    margin-bottom: 2rem;
}

.panel-title {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Form inputs & variables */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: hsl(var(--text-secondary));
    margin-bottom: 0.5rem;
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(255, 255, 255, 0.05);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Toggle Switches */
.switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--secondary)));
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* Drag & Drop Upload Zone */
.upload-zone {
    border: 2px dashed var(--glass-border);
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    background: rgba(255, 255, 255, 0.01);
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: hsl(var(--primary));
    background: rgba(14, 165, 233, 0.03);
}

.upload-icon {
    font-size: 3.5rem;
    color: hsl(var(--text-secondary));
    margin-bottom: 1rem;
    transition: var(--transition-smooth);
}

.upload-zone:hover .upload-icon {
    color: hsl(var(--primary));
    transform: scale(1.1);
}

.upload-text {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.upload-hint {
    color: hsl(var(--text-muted));
    font-size: 0.85rem;
}

/* Loading & Progress Panel */
.progress-container {
    text-align: center;
    padding: 2rem 0;
}

.progress-bar-wrapper {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    height: 20px;
    overflow: hidden;
    position: relative;
    margin: 1.5rem 0;
}

.progress-bar-fill {
    background: linear-gradient(to right, hsl(var(--primary)), hsl(var(--secondary)));
    height: 100%;
    width: 0%;
    border-radius: 1rem;
    transition: width 0.4s ease;
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.5);
}

.progress-text {
    font-size: 1.1rem;
    font-weight: 600;
}

.progress-details {
    color: hsl(var(--text-secondary));
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.console-log {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 1rem;
    font-family: monospace;
    font-size: 0.85rem;
    color: #38bdf8;
    height: 120px;
    overflow-y: auto;
    text-align: left;
    margin-top: 1.5rem;
}

/* Statistics Charts and Dashboard */
.results-dashboard {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: hsl(var(--text-secondary));
    margin-top: 0.25rem;
}

/* Custom CSS Charts */
.chart-container {
    margin-top: 2rem;
}

.chart-bar-group {
    margin-bottom: 1.5rem;
}

.chart-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.chart-bar-track {
    background: rgba(255, 255, 255, 0.05);
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
}

.chart-bar-segment {
    height: 100%;
    transition: var(--transition-smooth);
}

.segment-agree {
    background-color: hsl(var(--success));
}
.segment-disagree {
    background-color: hsl(var(--danger));
}
.segment-abstain {
    background-color: hsl(var(--warning));
}
.segment-other {
    background-color: hsl(var(--text-muted));
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 1.5rem;
    font-size: 0.85rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* Page by Page Review Layout */
.ballot-review-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
}

.ballot-row {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.25rem;
    transition: var(--transition-smooth);
}

.ballot-row:hover {
    border-color: rgba(14, 165, 233, 0.2);
    background: rgba(255, 255, 255, 0.04);
}

@media (max-width: 768px) {
    .ballot-row {
        grid-template-columns: 1fr;
    }
}

.ballot-preview {
    width: 100%;
    aspect-ratio: 3/4;
    background: #1e293b;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    cursor: zoom-in;
}

.ballot-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.ballot-preview:hover img {
    transform: scale(1.05);
}

.ballot-details {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ballot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ballot-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.ballot-status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge-completed {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34d399;
}
.status-badge-processing {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}
.status-badge-failed {
    background-color: rgba(244, 63, 94, 0.15);
    color: #f87171;
}

.ballot-votes-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.ballot-votes-table th, .ballot-votes-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.9rem;
}

.ballot-votes-table th {
    color: hsl(var(--text-secondary));
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.vote-select {
    background: #0f172a;
    border: 1px solid var(--glass-border);
    color: #ffffff;
    border-radius: 0.35rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    width: 100%;
}

.vote-select:focus {
    outline: none;
    border-color: hsl(var(--primary));
}

.vote-reason {
    color: hsl(var(--text-muted));
    font-size: 0.8rem;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal for Image Preview Zoom */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
}

.modal.active {
    display: flex;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #ffffff;
    font-size: 2.5rem;
    cursor: pointer;
    font-weight: bold;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: hsl(var(--primary));
}

/* Utilities */
.text-center { text-align: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.flex { display: flex; align-items: center; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mr-2 { margin-right: 0.5rem; }
