:root {
    --primary: #2563eb;
    --dark: #1e293b;
    --light: #f8fafc;
    --danger: #dc2626;
    --success: #16a34a;
    --border: #e2e8f0;
    --hover: #f1f5f9;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--light);
    color: #334155;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--dark) 100%);
    padding: 1rem;
}

.login-header {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.login-box {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    margin-bottom: 1.5rem;
    color: var(--dark);
}

/* Authenticated Layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--dark);
    color: white;
    padding: 1.5rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1rem;
}

.sidebar-brand h1 {
    font-size: 1.25rem;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 0.25rem;
}

.sidebar-nav a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

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

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 99;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: white;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.breadcrumbs {
    color: #64748b;
    font-size: 0.875rem;
}

.breadcrumbs a {
    color: var(--primary);
    text-decoration: none;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-menu span {
    font-weight: 500;
}

/* Content Area */
.content {
    padding: 2rem;
    flex: 1;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.content-header h1 {
    color: var(--dark);
    font-size: 1.75rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark);
}

.form-group label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

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

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

select.form-control {
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #64748b;
    color: #fff;
}
.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}
.btn-success:hover {
    background: #15803d;
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
}
.btn-warning:hover {
    background: #d97706;
}

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

.btn-info {
    background: #0ea5e9;
    color: #fff;
}
.btn-info:hover {
    background: #0284c7;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}


/* Tables */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

thead {
    background: var(--light);
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

td {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

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

.actions {
    display: flex;
    gap: 0.5rem;
    white-space: nowrap;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: #64748b;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

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

/* Flash Messages */
.flash-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
    max-width: 400px;
}

.flash {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
}

.flash.success {
    background: var(--success);
    color: white;
}

.flash.error {
    background: var(--danger);
    color: white;
}

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

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

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

.flash.hiding {
    animation: slideOut 0.3s ease forwards;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--dark);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    color: #64748b;
    font-size: 0.875rem;
}

/* Utility */
.text-muted {
    color: #64748b;
}

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* === RESPONSIVE === */

/* Tablets and below */
@media (max-width: 1024px) {
    .content {
        padding: 1.5rem;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    /* Sidebar mobile */
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Main content full width on mobile */
    .main-content {
        margin-left: 0;
    }
    
    /* Header */
    .header {
        padding: 1rem;
        padding-left: 3.5rem;
    }
    
    .breadcrumbs {
        font-size: 0.75rem;
    }
    
    .user-menu span {
        display: none;
    }
    
    /* Content */
    .content {
        padding: 1rem;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .content-header h1 {
        font-size: 1.5rem;
    }
    
    /* Tables */
    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8125rem;
    }
    
    .actions {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .actions .btn-sm {
        width: 100%;
        text-align: center;
    }
    
    /* Cards */
    .card {
        padding: 1rem;
    }
    
    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Flash messages */
    .flash-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
    
    /* Tabs */
    .tab {
        padding: 0.65rem 1rem;
        font-size: 0.875rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    /* Login */
    .login-box {
        padding: 1.5rem;
    }
    
    .login-header h1 {
        font-size: 1.5rem;
    }
    
    /* Header */
    .header {
        padding: 0.75rem;
        padding-left: 3rem;
    }
    
    /* Content */
    .content {
        padding: 0.75rem;
    }
    
    .content-header h1 {
        font-size: 1.25rem;
    }
    
    /* Buttons */
    .btn {
        width: 100%;
        text-align: center;
    }
    
    .btn + .btn {
        margin-top: 0.5rem;
    }
    
    /* Tables - minimal padding */
    th, td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
    
    /* Stats */
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.8125rem;
    }
}

/* Prevent zoom on input focus on iOS */
@media (max-width: 768px) {
    input, select, textarea, .form-control {
        font-size: 16px;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 220px;
    }
}




/* === RESPONSIVE TABLES === */
@media (max-width: 768px) {
    /* Превращаем таблицу в карточки на мобильных */
    .table-container {
        overflow-x: visible;
    }
    
    table {
        display: block;
    }
    
    thead {
        display: none;
    }
    
    tbody {
        display: block;
    }
    
    tbody tr {
        display: block;
        margin-bottom: 1rem;
        background: white;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 0.75rem;
    }
    
    tbody tr:hover {
        background: white;
    }
    
    td {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        border: none;
    }
    
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--dark);
        display: block;
        margin-bottom: 0.25rem;
        font-size: 0.75rem;
        text-transform: uppercase;
    }
    
    /* Скрываем label для actions */
    td.actions::before {
        display: none;
    }
    
    td.actions {
        display: flex;
        gap: 0.5rem;
        padding-top: 0.75rem;
        margin-top: 0.5rem;
        border-top: 1px solid var(--border);
    }
    
    td.actions .btn-sm {
        flex: 1;
    }
}