:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

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

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

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.navbar {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 15px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border);
}

.navbar-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.navbar-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.navbar-nav {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.navbar-nav a {
    color: var(--text);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 14px;
}

.navbar-nav a:hover, .navbar-nav a.active {
    background: var(--primary);
    color: white;
}

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

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

/* Grid */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Stat cards */
.stat-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.stat-card.success { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card.danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-card.info { background: linear-gradient(135deg, #3b82f6, #2563eb); }

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin: 8px 0;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

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

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border 0.2s;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea.form-control {
    min-height: 400px;
    resize: vertical;
    font-family: Georgia, serif;
    line-height: 1.8;
    font-size: 16px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
    font-family: inherit;
}

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

.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-secondary { background: #94a3b8; color: white; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

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

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 4px solid;
}

.alert-success { background: #d1fae5; border-color: var(--success); color: #065f46; }
.alert-danger { background: #fee2e2; border-color: var(--danger); color: #991b1b; }
.alert-warning { background: #fef3c7; border-color: var(--warning); color: #92400e; }
.alert-info { background: #dbeafe; border-color: var(--info); color: #1e40af; }

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

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

.table th {
    background: #f1f5f9;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.table tr:hover { background: #f8fafc; }

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-primary { background: #e0e7ff; color: #3730a3; }

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    color: var(--primary);
    font-size: 28px;
}

/* Esse analysis */
.mezon-item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    background: #f8fafc;
}

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

.mezon-title {
    font-weight: 600;
    color: var(--text);
}

.mezon-ball {
    font-size: 18px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 6px;
    background: var(--primary);
    color: white;
}

.mezon-izoh {
    font-size: 14px;
    color: var(--text-muted);
}

/* Xato highlighting */
.error-imlo {
    background: #fee2e2;
    border-bottom: 2px solid var(--danger);
    cursor: pointer;
    padding: 0 2px;
}

.error-ishora {
    background: #fef3c7;
    border-bottom: 2px solid var(--warning);
    cursor: pointer;
    padding: 0 2px;
}

.error-uslub {
    background: #dbeafe;
    border-bottom: 2px solid var(--info);
    cursor: pointer;
    padding: 0 2px;
}

.esse-display {
    padding: 20px;
    background: #fafafa;
    border-radius: 8px;
    font-family: Georgia, serif;
    line-height: 2;
    font-size: 16px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: #1e293b;
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    max-width: 320px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    line-height: 1.4;
}

.tooltip strong { color: #fbbf24; }

/* Score circle */
.score-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: conic-gradient(var(--primary) 0deg, var(--primary) var(--score-deg, 180deg), #e2e8f0 var(--score-deg, 180deg));
    position: relative;
    margin: 0 auto;
}

.score-circle::before {
    content: '';
    position: absolute;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: white;
}

.score-value {
    position: relative;
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
}

.score-max {
    position: relative;
    font-size: 14px;
    color: var(--text-muted);
}

/* Counter display */
.counter-display {
    display: flex;
    gap: 20px;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 10px;
}

.counter-item {
    color: var(--text-muted);
}

.counter-item strong {
    color: var(--primary);
    font-size: 16px;
}

/* Auto-save indicator */
.autosave-indicator {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    background: #f1f5f9;
    color: var(--text-muted);
}

.autosave-indicator.saved { background: #d1fae5; color: #065f46; }
.autosave-indicator.saving { background: #fef3c7; color: #92400e; }

/* Legend */
.error-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

/* Collapsible */
.collapsible {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.collapsible-header {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.collapsible-header:hover { background: #f1f5f9; }

.collapsible-body {
    padding: 16px;
    display: none;
    border-top: 1px solid var(--border);
}

.collapsible.open .collapsible-body { display: block; }

/* Loading */
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    gap: 20px;
    color: white;
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 16px; }
.hidden { display: none; }
