/* Reset and Base */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px 32px;
    min-height: 100vh;
}

/* No sidebar layout */
.app-container.no-sidebar .main-content {
    margin-left: 0;
    max-width: 100%;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--sidebar-text);
    letter-spacing: 1.5px;
    text-decoration: none;
}

.sidebar-logo:hover {
    text-decoration: none;
    opacity: 0.9;
}

.sidebar-nav-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-border) transparent;
}

.sidebar-nav-wrapper::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav-wrapper::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 3px;
}

.sidebar-nav-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--sidebar-text-secondary);
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin: 2px 12px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text-secondary);
    background: var(--sidebar-item-bg);
    transition: all 0.15s ease;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 450;
    border: 1px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text);
    text-decoration: none;
    border-color: var(--sidebar-border);
}

.sidebar-nav .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    opacity: 0.85;
}

.sidebar-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 14px 20px;
}

.sidebar-section-title {
    padding: 10px 26px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sidebar-text-secondary);
    font-weight: 600;
    opacity: 0.7;
}

/* Header */
/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.breadcrumb-item {
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    transition: color 0.15s ease;
}

.breadcrumb-item:hover {
    color: var(--accent);
}

.breadcrumb-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.breadcrumb-home svg {
    opacity: 0.7;
}

.breadcrumb-home:hover svg {
    opacity: 1;
}

.breadcrumb-separator {
    color: var(--text-secondary);
    opacity: 0.5;
    font-size: 12px;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
}

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

.page-title {
    font-size: 26px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.3px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

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

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

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card.positive .stat-value {
    color: var(--success);
}

.stat-card.negative .stat-value {
    color: var(--danger);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

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

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 113, 227, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 6px rgba(0, 113, 227, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    opacity: 0.9;
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-warning:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

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

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

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

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.form-control:hover {
    border-color: var(--text-muted);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236e6e73' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
    cursor: pointer;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-check-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

.form-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.form-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 6px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 10px;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.table th:first-child {
    border-radius: 10px 0 0 0;
}

.table th:last-child {
    border-radius: 0 10px 0 0;
}

.table td {
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color 0.1s ease;
}

.table tbody tr:nth-child(even) {
    background: var(--bg-stripe);
}

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

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

.table tbody tr:last-child td:first-child {
    border-radius: 0 0 0 10px;
}

.table tbody tr:last-child td:last-child {
    border-radius: 0 0 10px 0;
}

.table-actions {
    display: flex;
    gap: 8px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    letter-spacing: 0.2px;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info-text);
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success);
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info-text);
    border: 1px solid var(--info);
}

/* Pagination */
.pagination {
    display: flex;
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.pagination a:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.pagination .active span {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* News Items */
.news-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.news-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.1s ease;
}

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

.news-item:last-child {
    border-bottom: none;
}

.news-image {
    width: 120px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.news-content {
    flex: 1;
    min-width: 0;
}

.news-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 6px;
    line-height: 1.4;
}

.news-title a {
    color: var(--text-primary);
}

.news-title a:hover {
    color: var(--accent);
    text-decoration: none;
}

.news-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.news-source {
    color: var(--text-secondary);
    font-weight: 500;
}

.news-source:hover {
    color: var(--accent);
}

/* Code Block */
.code-block {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 16px;
    overflow-x: auto;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.code-block pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-secondary);
    border-radius: 14px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-title {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 18px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

.toast {
    padding: 14px 18px;
    border-radius: 10px;
    margin-top: 10px;
    min-width: 280px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

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

/* User Menu */
.user-menu {
    flex-shrink: 0;
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--sidebar-item-bg, var(--sidebar-hover));
    border: 1px solid var(--sidebar-border);
    border-radius: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--sidebar-text);
}

.user-role {
    font-size: 12px;
    color: var(--sidebar-text-secondary);
}

.user-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.user-actions .btn {
    flex: 1;
    justify-content: center;
    align-items: center;
    padding: 9px 14px;
    min-height: 38px;
    background: var(--sidebar-item-bg, var(--sidebar-hover));
    color: var(--sidebar-text);
    border: 1px solid var(--sidebar-border);
    font-size: 13px;
    line-height: 1;
}

.user-actions .btn:hover {
    background: var(--sidebar-hover);
}

/* Theme Switcher */
.theme-switcher {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 8px;
    background: var(--sidebar-item-bg, var(--sidebar-hover));
    border: 1px solid var(--sidebar-border);
    transition: all 0.15s ease;
    font-size: 13px;
    color: var(--sidebar-text-secondary);
    font-weight: 500;
}

.theme-switcher:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.theme-icon {
    font-size: 16px;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: -260px;
        transition: left 0.3s ease;
        z-index: 100;
    }

    .sidebar.open {
        left: 0;
    }

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

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

@media (max-width: 576px) {
    .main-content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .card {
        padding: 16px;
        border-radius: 10px;
    }
}
