/* ========================================
   Корпоративный ERP стиль
   ======================================== */

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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --bg-color: #ecf0f1;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --hover-color: #2980b9;
}

body {
    font-family: 'Arial', 'Helvetica', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* ========================================
   Layout
   ======================================== */

.layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 20px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ========================================
   Header
   ======================================== */

.header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.header-title {
    font-size: 20px;
    font-weight: 600;
}

.header-nav {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-link:hover {
    background-color: var(--secondary-color);
}

.nav-link-icon {
    padding: 8px 12px;
}

.nav-link-icon svg {
    display: block;
}

.user-link {
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    color: #ecf0f1;
    font-size: 14px;
}

/* ========================================
   Footer
   ======================================== */

.footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 15px;
    font-size: 12px;
}

/* ========================================
   Cards & Containers
   ======================================== */

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

/* Order Header - colors set inline from database */
.order-header {
    padding: 20px;
    border-bottom: none;
    margin-bottom: 0;
}

.order-info-list {
    margin: 0;
    padding: 0;
}

.order-info-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 16px;
    line-height: 1.4;
}

.order-info-row:last-child {
    margin-bottom: 0;
}

.order-info-row dt {
    font-weight: 400;
    opacity: 0.9;
    white-space: nowrap;
}

.order-info-row dd {
    margin: 0;
    font-weight: 600;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.card-body {
    padding: 10px 0;
}

/* ========================================
   Tables
   ======================================== */

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

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

table th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
}

table tbody tr:hover {
    background-color: #f8f9fa;
}

table tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

/* ========================================
   Forms
   ======================================== */

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

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

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
}

select.form-control {
    cursor: pointer;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

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

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

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

.btn-success:hover {
    background-color: #229954;
}

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

.btn-warning:hover {
    background-color: #e67e22;
}

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

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

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

.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* ========================================
   Search & Filters
   ======================================== */

.search-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-box {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-box input {
    flex: 1;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

/* ========================================
   Badges & Status
   ======================================== */

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

.badge-success {
    background-color: #d4edda;
    color: #155724;
}

.badge-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.badge-warning {
    background-color: #fff3cd;
    color: #856404;
}

.badge-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.badge-secondary {
    background-color: #e2e3e5;
    color: #383d41;
}

/* ========================================
   Modal
   ======================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px 0;
}

.modal-footer {
    border-top: 2px solid var(--bg-color);
    padding-top: 15px;
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ========================================
   Alerts & Messages
   ======================================== */

.alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-success {
    background-color: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.alert-error,
.alert-danger {
    background-color: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

/* ========================================
   Statistics & Dashboard
   ======================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.stat-title {
    font-size: 14px;
    color: #7f8c8d;
    margin: 0;
    flex: 1;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    white-space: nowrap;
}

/* Order stats line */
.order-stats-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.order-stats-separator {
    color: #bdc3c7;
    margin: 0 4px;
}

@media (max-width: 768px) {
    .order-stats-line {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .order-stats-separator {
        display: none;
    }
}

/* ========================================
   Tabs Component
   ======================================== */

.tabs-header {
    display: flex;
    border-bottom: 2px solid var(--bg-color);
    padding: 0 20px;
    background: #fafbfc;
    border-radius: 8px 8px 0 0;
}

.tab-btn {
    padding: 15px 25px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #7f8c8d;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(0,0,0,0.02);
}

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

.tab-content {
    display: none;
    padding: 20px;
}

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

/* ========================================
   Clickable Badges
   ======================================== */

.badge-clickable {
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.badge-clickable:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.barcode-code {
    transition: all 0.2s;
}

.barcode-code:hover {
    background: #e3f2fd;
    color: var(--accent-color);
}

/* ========================================
   Package Cards
   ======================================== */

.package-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.package-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-top: 4px solid var(--accent-color);
}

.package-card.closed {
    border-top-color: var(--success-color);
}

.package-card.open {
    border-top-color: var(--warning-color);
}

/* ========================================
   Barcode Display
   ======================================== */

.barcode-display {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 8px;
    margin: 20px 0;
}

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

.barcode-value {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    margin-top: 10px;
}

/* ========================================
   Utility Classes
   ======================================== */

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

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

.mb-20 {
    margin-bottom: 20px;
}

.mt-20 {
    margin-top: 20px;
}

.hidden {
    display: none;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ========================================
   Responsive
   ======================================== */

/* ========================================
   Orders Panel (Sidebar)
   ======================================== */

.sidebar-orders {
    position: fixed;
    left: -320px;
    top: 0;
    width: 320px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transition: left 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar-orders.active {
    left: 0;
}

.sidebar-orders-header {
    padding: 20px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary-color);
    color: white;
}

.sidebar-orders-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.sidebar-orders-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.sidebar-orders-close:hover {
    background: rgba(255,255,255,0.2);
}

.sidebar-orders-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.orders-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.order-node {
    margin-bottom: 10px;
}

.order-header {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid #3498db;
}

.order-header:hover {
    background: #e9ecef;
    transform: translateX(2px);
}

.order-header.active {
    background: #e3f2fd;
    border-left-color: #2196F3;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.2);
}

.order-toggle {
    margin-right: 8px;
    font-size: 12px;
    transition: transform 0.2s;
    color: #666;
}

.order-node.expanded .order-toggle {
    transform: rotate(90deg);
}

.order-info {
    flex: 1;
}

.order-number {
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
    margin-bottom: 2px;
}

.order-name {
    font-size: 12px;
    color: #7f8c8d;
}

.order-items {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 20px;
    display: none;
}

.order-node.expanded .order-items {
    display: block;
}

.order-item {
    padding: 10px 12px;
    margin: 4px 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-item:hover {
    background: #f8f9fa;
    border-color: #2196F3;
    transform: translateX(4px);
}

.order-item.active {
    background: #e3f2fd;
    border-color: #2196F3;
    border-left-width: 3px;
}

.order-item-icon {
    font-size: 16px;
    color: #2196F3;
}

.order-item-info {
    flex: 1;
    min-width: 0;
}

.order-item-partnumber {
    font-weight: 600;
    font-size: 13px;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-item-partname {
    font-size: 11px;
    color: #7f8c8d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-item-count {
    font-size: 12px;
    color: #666;
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

/* Плавающая кнопка заказов удалена - используется пункт меню */

/* Overlay для закрытия панели */
.sidebar-orders-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    z-index: 999;
    display: none;
}

.sidebar-orders-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .header-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .filters {
        grid-template-columns: 1fr;
    }
    
    .sidebar-orders {
        width: 280px;
        left: -280px;
    }
    
    .btn-toggle-orders.active {
        left: 300px;
    }
}



