/* ============================================
   admin.css - Стили для административной части
   МАУ МБС г. Твери - Продление книг
   ============================================ */

/* ===== CSS Variables ===== */
:root {
    --primary: #2c6e49;
    --primary-dark: #1a4a2e;
    --primary-light: #4c9a6e;
    --primary-bg: #e8f5ee;
    --secondary: #f4a261;
    --danger: #e76f51;
    --success: #2a9d8f;
    --info: #4a90d9;
    --gray-50: #f8f9fa;
    --gray-100: #e9ecef;
    --gray-200: #dee2e6;
    --gray-300: #ced4da;
    --gray-400: #adb5bd;
    --gray-500: #8c959f;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    --shadow: 0 2px 4px -1px rgba(0,0,0,0.06), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 6px;
    --transition: all 0.25s ease;
    --sidebar-width: 260px;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: none;
}

/* ============================================
   AUTH PAGE
   ============================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8edf2 100%);
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: white;
    padding: 40px 36px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-icon {
    font-size: 52px;
    display: block;
    margin-bottom: 8px;
}

.auth-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.auth-header p {
    color: var(--gray-600);
    font-size: 14px;
}

.auth-error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    text-align: center;
    font-size: 14px;
}

.auth-success {
    background: #d4edda;
    color: #155724;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    text-align: center;
    font-size: 14px;
}

.auth-form .form-group {
    margin-bottom: 16px;
}

.auth-form .form-group label {
    display: block;
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--gray-700);
}

.auth-form .form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: var(--transition);
}

.auth-form .form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 110, 73, 0.12);
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 16px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
}

.auth-footer a {
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
}

.auth-footer a:hover {
    color: var(--primary);
}

/* ============================================
   ADMIN WRAPPER (Sidebar + Content)
   ============================================ */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 50;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

.sidebar-header {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 20px;
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.logout-link {
    font-size: 13px;
    color: var(--danger);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 4px;
    transition: var(--transition);
}

.logout-link:hover {
    background: #f8d7da;
    color: #c0392b;
    text-decoration: none;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    text-decoration: none;
    transition: var(--transition);
    margin-bottom: 2px;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
}

.sidebar-nav a:hover {
    background: var(--gray-100);
    color: var(--gray-900);
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--primary);
    color: white;
}

.sidebar-nav a.active:hover {
    background: var(--primary-dark);
}

.sidebar-nav a .icon {
    font-size: 18px;
}

.sidebar-nav a .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    padding: 1px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* ===== Admin Content ===== */
.admin-content {
    flex: 1;
    padding: 24px 32px;
    min-width: 0;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.admin-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--gray-900);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.header-actions select,
.header-actions input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: white;
    cursor: pointer;
    color: var(--gray-700);
}

.header-actions select:focus,
.header-actions input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 110, 73, 0.1);
}

.count-badge {
    background: var(--gray-200);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.filter-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    padding: 20px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card.success {
    border-left-color: var(--success);
}

.stat-card.danger {
    border-left-color: var(--danger);
}

.stat-card.warning {
    border-left-color: var(--secondary);
}

.stat-card.info {
    border-left-color: var(--info);
}

.stat-number {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-900);
}

.stat-label {
    font-size: 14px;
    color: var(--gray-600);
    margin-top: 2px;
}

.stat-change {
    font-size: 13px;
    margin-top: 4px;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* ============================================
   TABLES
   ============================================ */
.table-section {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
    margin: 0 -24px;
    padding: 0 24px;
}

.requests-table,
.stats-table,
.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.requests-table th,
.stats-table th,
.logs-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--gray-200);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.requests-table td,
.stats-table td,
.logs-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.requests-table tr:hover,
.stats-table tr:hover,
.logs-table tr:hover {
    background: var(--gray-50);
}

.requests-table td:last-child {
    white-space: nowrap;
}

/* ============================================
   STATUS BADGES
   ============================================ */
.status-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.pending {
    background: #fff3cd;
    color: #856404;
}

.status-badge.approved {
    background: #d4edda;
    color: #155724;
}

.status-badge.rejected {
    background: #f8d7da;
    color: #721c24;
}

/* ============================================
   BUTTONS (Admin specific)
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
    min-height: 36px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    text-decoration: none;
    color: white;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
    transform: translateY(-1px);
    text-decoration: none;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #21867a;
    transform: translateY(-1px);
    text-decoration: none;
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-1px);
    text-decoration: none;
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
}

.btn-outline:hover {
    background: var(--gray-100);
    transform: translateY(-1px);
    text-decoration: none;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
    min-height: 28px;
    border-radius: 4px;
}

.btn-approve {
    background: var(--success);
    color: white;
}

.btn-approve:hover {
    background: #21867a;
    color: white;
    text-decoration: none;
}

.btn-reject {
    background: var(--danger);
    color: white;
}

.btn-reject:hover {
    background: #c0392b;
    color: white;
    text-decoration: none;
}

.btn-delete {
    background: var(--gray-600);
    color: white;
}

.btn-delete:hover {
    background: #5a6268;
    color: white;
    text-decoration: none;
}

/* ============================================
   ACTIONS
   ============================================ */
.actions-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ============================================
   SEARCH
   ============================================ */
.search-box {
    position: relative;
}

.search-box input {
    padding: 8px 14px 8px 36px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    width: 220px;
    transition: var(--transition);
    background: white;
    color: var(--gray-700);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    width: 280px;
    box-shadow: 0 0 0 3px rgba(44, 110, 73, 0.1);
}

.search-box::before {
    content: "🔍";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
}

/* ============================================
   CHART SECTION
   ============================================ */
.chart-section {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.chart-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--gray-800);
}

.chart-container {
    position: relative;
    height: 280px;
}

.chart-container.small {
    height: 200px;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: 18px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-600);
    padding: 0 4px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-body {
    padding: 20px 24px;
}

.modal-body textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: var(--transition);
}

.modal-body textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 110, 73, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
}

/* ============================================
   LOG ACTIONS
   ============================================ */
.log-action {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.log-action.login {
    background: #d1ecf1;
    color: #0c5460;
}

.log-action.approve {
    background: #d4edda;
    color: #155724;
}

.log-action.reject {
    background: #f8d7da;
    color: #721c24;
}

.log-action.delete {
    background: #e2e3e5;
    color: #383d41;
}

.log-comment {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   TEXT COLORS
   ============================================ */
.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-muted {
    color: var(--gray-600);
}

/* ============================================
   RESPONSIVE - ADMIN
   ============================================ */

/* Large tablets / small laptops */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 220px;
    }
    
    .admin-content {
        padding: 20px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    .admin-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 16px;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .sidebar-nav a {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .sidebar-nav a .badge {
        display: none;
    }
    
    .admin-content {
        padding: 16px;
    }
    
    .admin-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .admin-header h1 {
        font-size: 22px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .header-actions {
        flex-wrap: wrap;
    }
    
    .search-box input {
        width: 100%;
    }
    
    .search-box input:focus {
        width: 100%;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .modal-content {
        margin: 16px;
    }
    
    .requests-table td,
    .stats-table td,
    .logs-table td {
        font-size: 13px;
        padding: 8px 10px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar-nav {
        flex-direction: column;
    }
    
    .sidebar-nav a {
        padding: 8px 12px;
    }
    
    .admin-content {
        padding: 12px;
    }
    
    .table-section {
        padding: 12px 16px;
    }
    
    .actions-group {
        flex-direction: column;
        gap: 4px;
    }
    
    .actions-group .btn-sm {
        width: 100%;
        justify-content: center;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
    
    .filter-group {
        flex-direction: column;
    }
    
    .filter-group select {
        width: 100%;
    }
}