/* SSA Platform - Main Stylesheet */

:root {
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --border-color: #e5e7eb;
    --text-muted: #6b7280;
    --bg-light: #f9fafb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

[data-bs-theme="dark"] {
    --bg-light: #1f2937;
    --border-color: #374151;
    --text-muted: #9ca3af;
}

/* Typography */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #fff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease;
}

[data-bs-theme="dark"] .sidebar {
    background: #111827;
    border-color: #1f2937;
}

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

.sidebar-brand {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    padding: 0 1.25rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    color: #374151;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

[data-bs-theme="dark"] .sidebar .nav-link {
    color: #d1d5db;
}

.sidebar .nav-link i {
    width: 1.5rem;
    font-size: 1.125rem;
    margin-right: 0.75rem;
}

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

.sidebar .nav-link.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    font-weight: 500;
}

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

.sidebar-footer .avatar {
    font-size: 1.5rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-light);
    display: flex;
    flex-direction: column;
}

/* Съдържанието расте, за да избута EU футъра винаги най-долу */
.page-content {
    flex: 1 0 auto;
}

.eu-footer {
    flex-shrink: 0;
}

.topbar {
    height: var(--topbar-height);
    padding: 0 1.5rem;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
}

[data-bs-theme="dark"] .topbar {
    background: #111827;
    border-color: #1f2937;
}

.page-content {
    padding: 1.5rem;
}

/* Cards */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

/* KPI Cards */
.kpi-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

[data-bs-theme="dark"] .kpi-card {
    background: #1f2937;
}

.kpi-card .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-card .kpi-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.kpi-card .kpi-change {
    font-size: 0.75rem;
    font-weight: 500;
}

.kpi-change.positive {
    color: var(--success-color);
}

.kpi-change.negative {
    color: var(--danger-color);
}

/* Tables */
.table-container {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

[data-bs-theme="dark"] .table-container {
    background: #1f2937;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: var(--bg-light);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom-width: 1px;
    padding: 0.875rem 1rem;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

[data-bs-theme="dark"] .table thead th {
    background: #111827;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
}

.table-hover tbody tr:hover {
    background: rgba(79, 70, 229, 0.04);
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

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

.btn-soft-primary {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    border: none;
}

.btn-soft-primary:hover {
    background: rgba(79, 70, 229, 0.2);
    color: var(--primary-color);
}

/* Badges */
.badge-soft {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

.badge-soft-primary {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.badge-soft-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.badge-soft-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.badge-soft-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

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

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
}

/* Htaccess Editor Specific */
.htaccess-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    height: calc(100vh - var(--topbar-height) - 3rem);
}

.htaccess-builder {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.htaccess-preview {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rules-list {
    flex: 1;
    overflow-y: auto;
}

.rule-item {
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    background: #fff;
    cursor: move;
    transition: all 0.15s ease;
}

[data-bs-theme="dark"] .rule-item {
    background: #1f2937;
}

.rule-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.rule-item.disabled {
    opacity: 0.5;
}

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

.rule-item .rule-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.025em;
}

.rule-item .rule-name {
    font-weight: 500;
}

.code-preview {
    flex: 1;
    overflow: auto;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    border-radius: var(--radius);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-preview .comment {
    color: #6a9955;
}

.code-preview .directive {
    color: #569cd6;
}

.code-preview .string {
    color: #ce9178;
}

/* Diff View */
.diff-view {
    font-family: monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
}

.diff-line {
    padding: 0.125rem 0.5rem;
}

.diff-add {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
}

.diff-remove {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius);
}

[data-bs-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
}

/* Country flags */
.country-flag {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    object-fit: cover;
}

/* Status indicators */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active {
    background: var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .htaccess-editor {
        grid-template-columns: 1fr;
    }
}

/* Empty states */
.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state h5 {
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Filters bar */
.filters-bar {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

[data-bs-theme="dark"] .filters-bar {
    background: #1f2937;
}

/* Tabs */
.nav-tabs-custom {
    border-bottom: 2px solid var(--border-color);
}

.nav-tabs-custom .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

.nav-tabs-custom .nav-link:hover {
    color: var(--primary-color);
}

.nav-tabs-custom .nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: transparent;
}

/* Timeline (for history) */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 0.25rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid #fff;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

/* Utilities */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

.hover-shadow:hover {
    box-shadow: var(--shadow-md);
}

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

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

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}
