/* ============================================
   FACTORY MANAGEMENT SYSTEM - MODERN PROFESSIONAL DESIGN
   Square-shaped, Clean, User-friendly Interface
   ============================================ */

/* ========== ROOT VARIABLES ========== */
:root {
    /* Primary Colors */
    --primary-color: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #6366F1;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Neutral Colors */
    --dark-color: #0F172A;
    --gray-900: #1E293B;
    --gray-800: #334155;
    --gray-700: #475569;
    --gray-600: #64748B;
    --gray-500: #94A3B8;
    --gray-400: #CBD5E1;
    --gray-300: #E2E8F0;
    --gray-200: #F1F5F9;
    --gray-100: #F8FAFC;
    --white: #FFFFFF;
    
    /* Status Colors */
    --success-color: #10B981;
    --success-light: #D1FAE5;
    --danger-color: #EF4444;
    --danger-light: #FEE2E2;
    --warning-color: #F59E0B;
    --warning-light: #FEF3C7;
    --info-color: #3B82F6;
    --info-light: #DBEAFE;
    
    /* Layout */
    --sidebar-width: 280px;
    --header-height: 72px;
    --content-max-width: 1400px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --transition-fast: all 0.15s ease;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
}

/* ========== RESET & BASE ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ========== SIDEBAR - MODERN PROFESSIONAL ========== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--white);
    border-right: 1px solid var(--gray-300);
    overflow-y: auto;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-full);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Sidebar Logo */
.sidebar-logo {
    padding: 24px 20px;
    border-bottom: 1px solid var(--gray-200);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.sidebar-logo h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.sidebar-logo h2 .icon {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.sidebar-logo p {
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    margin: 4px 0 0 40px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Sidebar Menu */
.sidebar-menu {
    list-style: none;
    padding: 16px 12px;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--gray-700);
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition-fast);
    font-weight: 500;
    font-size: 14px;
    position: relative;
}

.sidebar-menu a:hover {
    background: var(--gray-100);
    color: var(--primary-color);
    transform: translateX(2px);
}

.sidebar-menu a.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.sidebar-menu a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: var(--white);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.sidebar-menu .icon {
    font-size: 20px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* ========== HEADER - MODERN PROFESSIONAL ========== */
.header {
    position: fixed;
    left: var(--sidebar-width);
    top: 0;
    right: 0;
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 999;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header-search {
    position: relative;
    width: 400px;
}

.header-search input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: 14px;
    transition: var(--transition-fast);
    background: var(--gray-100);
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.header-search::before {
    content: '🔍';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--gray-100);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: var(--transition-fast);
}

.header-icon-btn:hover {
    background: var(--gray-200);
    transform: translateY(-2px);
}

.header-icon-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger-color);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-lg);
    background: var(--gray-100);
    cursor: pointer;
    transition: var(--transition-fast);
}

.user-menu:hover {
    background: var(--gray-200);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    box-shadow: var(--shadow);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-900);
}

.user-role {
    font-size: 12px;
    color: var(--gray-600);
}

/* ========== CONTENT AREA ========== */
.content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 32px;
    min-height: calc(100vh - var(--header-height));
    max-width: var(--content-max-width);
}

/* ========== PAGE HEADER ========== */
.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-subtitle {
    font-size: 16px;
    color: var(--gray-600);
    font-weight: 400;
}

/* ========== CARDS - MODERN SQUARE DESIGN ========== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid var(--gray-200);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ========== STAT CARDS - PROFESSIONAL ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-light) 100%);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: var(--gray-600);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
}

.stat-icon.success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
}

.stat-icon.danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.1) 100%);
}

.stat-icon.warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(217, 119, 6, 0.1) 100%);
}

.stat-icon.info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(37, 99, 235, 0.1) 100%);
}

/* ========== BUTTONS - MODERN SQUARE ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-warning {
    background: var(--warning-color);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-outline:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
    display: flex;
}

/* ========== FORMS - PROFESSIONAL ========== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: var(--transition-fast);
    background: var(--white);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 40px;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* ========== TABLES - MODERN PROFESSIONAL ========== */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--white);
}

.table thead {
    background: var(--gray-50);
}

.table thead th {
    padding: 16px 20px;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}

.table tbody tr {
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--gray-200);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table tbody td {
    padding: 16px 20px;
    font-size: 14px;
    color: var(--gray-700);
}

/* ========== BADGES - SQUARE MODERN ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.badge-success {
    background: var(--success-light);
    color: var(--success-color);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger-color);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning-color);
}

.badge-info {
    background: var(--info-light);
    color: var(--info-color);
}

/* ========== ALERTS - PROFESSIONAL ========== */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    border-left: 4px solid;
    font-size: 14px;
    font-weight: 500;
}

.alert-success {
    background: var(--success-light);
    color: var(--success-color);
    border-color: var(--success-color);
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-color);
    border-color: var(--warning-color);
}

.alert-info {
    background: var(--info-light);
    color: var(--info-color);
    border-color: var(--info-color);
}

/* ========== GRID SYSTEM ========== */
.grid {
    display: grid;
    gap: 24px;
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ========== UTILITIES ========== */
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.align-center { align-items: center; }
.gap-2 { gap: 16px; }
.text-center { text-align: center; }
.text-secondary { color: var(--gray-600); }
.mt-2 { margin-top: 16px; }
.mt-4 { margin-top: 32px; }
.mb-2 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 32px; }
.p-2 { padding: 16px; }
.p-4 { padding: 32px; }

/* ========== QUICK ACCESS PANEL ========== */
.quick-access {
    position: fixed;
    right: 32px;
    bottom: 32px;
    z-index: 1000;
}

.quick-access-btn {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-xl);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-access-btn:hover {
    transform: scale(1.1) rotate(90deg);
}

/* ========== MOBILE MENU BUTTON ========== */
.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius);
    color: var(--white);
    font-size: 24px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    box-shadow: var(--shadow);
}

.mobile-menu-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: var(--sidebar-width);
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1001;
        box-shadow: var(--shadow-xl);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .header {
        left: 0;
        padding: 0 16px;
    }
    
    .content {
        margin-left: 0;
        padding: 16px;
        margin-top: var(--header-height);
    }
    
    .header-search {
        display: none;
    }
    
    .header-left {
        gap: 12px;
    }
    
    .user-info {
        display: none;
    }
    
    .user-menu {
        padding: 8px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
    
    .grid-cols-md-2,
    .grid-cols-md-3,
    .grid-cols-md-4 {
        grid-template-columns: 1fr;
    }
    
    .page-title {
        font-size: 24px;
    }
    
    .page-subtitle {
        font-size: 14px;
    }
    
    .card {
        margin-bottom: 16px;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .quick-access-menu {
        right: 16px;
        bottom: 16px;
    }
    
    .quick-access-toggle {
        width: 56px;
        height: 56px;
    }
}

@media (min-width: 768px) {
    .grid-cols-md-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-md-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-cols-md-4 { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
    .grid-cols-lg-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-cols-lg-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ========== PRINT STYLES ========== */
@media print {
    .sidebar,
    .header,
    .btn,
    .quick-access {
        display: none !important;
    }
    
    .content {
        margin: 0;
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
}

/* ========== LOGIN PAGE ========== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: var(--white);
    padding: 48px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 450px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.login-logo p {
    font-size: 14px;
    color: var(--gray-600);
}
