/* Variables */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* App Container */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 30px;
}

.header h1 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Language Switcher */
.lang-switcher {
    position: relative;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.lang-icon {
    font-size: 1.1rem;
}

.lang-current {
    font-size: 0.85rem;
    font-weight: 500;
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    min-width: 140px;
}

.lang-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.lang-option:hover {
    background: var(--bg-hover);
}

.lang-option.active {
    background: var(--primary);
    color: white;
}

.lang-flag {
    font-size: 1.2rem;
}

/* QR Header Wrapper */
.qr-header-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.qr-label {
    font-size: 0.65rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Mini QR Code */
.mini-qr {
    width: 80px;
    height: 80px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 0 2px var(--primary), 0 4px 12px rgba(99, 102, 241, 0.3);
    padding: 4px;
}

.mini-qr:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px var(--primary), 0 8px 20px rgba(99, 102, 241, 0.4);
}

.mini-qr canvas {
    width: 100%;
    height: 100%;
    border-radius: 4px;
}

/* QR Modal */
.qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.qr-modal-content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--radius);
    text-align: center;
    position: relative;
    max-width: 320px;
    width: 90%;
}

.qr-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

.qr-close:hover {
    color: var(--text);
}

.qr-modal-content h3 {
    margin-bottom: 20px;
    color: var(--text);
}

.qr-container {
    background: var(--bg);
    padding: 15px;
    border-radius: 8px;
    display: inline-block;
}

.qr-container canvas {
    display: block;
}

.qr-hint {
    margin-top: 15px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.qr-url {
    margin: 15px 0;
    padding: 10px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    word-break: break-all;
    max-height: 60px;
    overflow-y: auto;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
}

/* Overlap Group */
.overlap-group {
    position: relative;
}

.overlap-hint {
    margin-top: 12px;
    padding: 12px 15px;
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--primary);
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.overlap-hint p {
    color: var(--text-muted);
    margin: 0;
}

.overlap-hint .overlap-example {
    margin-top: 8px;
    color: var(--primary);
    font-weight: 500;
    font-size: 0.85rem;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

input[type="range"] {
    width: 100%;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: var(--border);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
}

.tab {
    flex: 1;
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.tab.active {
    background: var(--primary);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Legend */
.legend {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px 24px;
    margin-bottom: 20px;
}

.legend h4 {
    margin-bottom: 12px;
    color: var(--text-muted);
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.legend-item {
    background: var(--bg);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: help;
    transition: background 0.2s;
}

.legend-item:hover {
    background: var(--bg-hover);
}

/* Voting Section */
.voting-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.voting-parameter {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
}

.voting-parameter h4 {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

/* Cards (Voting) */
.cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.vote-card {
    width: 50px;
    height: 70px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.vote-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.vote-card.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-4px);
}

.vote-card.skip {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.vote-card.skip.selected {
    background: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

.vote-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.vote-status.voted {
    color: var(--success);
}

/* Participants */
.participants-card {
    background: var(--bg-card);
}

.participants-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.participant {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.participant-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--secondary);
}

.participant-status.voted {
    background: var(--success);
}

.participant-status.partial {
    background: var(--warning);
}

/* Actions */
.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 24px;
}

/* Results */
.results-card {
    text-align: center;
}

.results-card h2 {
    margin-bottom: 16px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.chart-container {
    background: var(--bg);
    border-radius: 8px;
    padding: 16px;
}

.chart-container h4 {
    margin-bottom: 12px;
}

.chart-container canvas {
    max-height: 200px;
}

.median-badge {
    background: var(--primary);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 12px;
    font-weight: 500;
}

/* Summary */
.summary {
    background: var(--bg);
    border-radius: 8px;
    padding: 20px;
    max-width: 400px;
    margin: 0 auto 24px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row.total {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
}

/* Task Card */
.task-card {
    position: relative;
}

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

.task-name {
    font-size: 1.1rem;
    color: var(--text);
}

.task-edit-input {
    margin-top: 10px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--primary);
    padding: 14px 20px;
    border-radius: 8px;
    margin-top: 10px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--danger);
}

.toast.warning {
    border-color: var(--warning);
}

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

/* Screen transitions */
.screen {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .voting-section {
        grid-template-columns: 1fr;
    }

    .vote-card {
        width: 42px;
        height: 60px;
        font-size: 1rem;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* Success Button */
.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
    transform: translateY(-1px);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--radius);
    max-width: 450px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 10px;
    color: var(--text);
}

.modal-content p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions .btn {
    flex: 1;
}

/* Statistics Card */
.statistics-card {
    margin-top: 20px;
}

.statistics-card h3 {
    margin-bottom: 20px;
    text-align: center;
}

.stats-summary {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

/* Task History List */
.task-history {
    max-height: 300px;
    overflow-y: auto;
}

.no-tasks {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 8px;
}

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

.history-task-name {
    font-weight: 500;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 16px;
}

.history-estimate {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.history-medians {
    display: flex;
    gap: 8px;
    margin-left: 12px;
}

.history-median {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 4px;
}

/* History Card on Voting Screen */
.history-card {
    margin-top: 20px;
}

.history-card h4 {
    margin-bottom: 12px;
}

.history-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.history-stats span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.history-stats strong {
    color: var(--primary);
    font-size: 1.1rem;
}

.history-table-container {
    max-height: 250px;
    overflow-y: auto;
}

/* History Table */
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.history-table th,
.history-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.history-table th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    position: sticky;
    top: 0;
}

.history-table td {
    color: var(--text);
}

.history-table tr:hover td {
    background: var(--bg-hover);
}

.history-table .task-name-cell {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-table .estimate-cell {
    text-align: center;
    font-weight: 500;
}

.history-table .total-cell {
    color: var(--primary);
    font-weight: bold;
}

/* Footer */
.app-footer {
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-author {
    font-weight: 500;
}

.footer-link {
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--text);
}

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

.footer-license {
    opacity: 0.7;
}
