/* =============================================
   Machinery Store - Admin Panel CSS
   Modern Dark Theme with Enhanced Responsiveness
   ============================================= */

/* === Google Fonts Import === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Poppins:wght@400;500;600;700;800&display=swap');

/* === CSS Variables === */
:root {
    /* Colors */
    --primary-color: #0f172a;
    --primary-light: #1e293b;
    --accent-color: #f59e0b;
    --accent-light: #fbbf24;
    --accent-gradient: linear-gradient(135deg, #f59e0b 0%, #f97316 50%, #ea580c 100%);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;

    /* Backgrounds */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #0f172a;

    /* Text */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Status Colors */
    --success-color: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger-color: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);

    /* Borders & Shadows */
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.3);

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Poppins', 'Inter', sans-serif;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset & Base === */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body.admin-panel,
body.login-page {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-base);
}

ul {
    list-style: none;
}

/* === Login Page === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at top, rgba(245, 158, 11, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.login-box {
    background: var(--bg-secondary);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

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

.login-header h1 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.login-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.login-form input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-family: var(--font-primary);
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition-base);
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

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

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.login-footer a {
    color: var(--accent-color);
    font-weight: 500;
}

.login-footer a:hover {
    text-decoration: underline;
}

.login-footer .text-muted {
    color: var(--text-muted);
    margin-top: 1rem;
    display: block;
    font-size: 0.85rem;
}

/* === Admin Panel Layout === */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: var(--transition-slow);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.admin-username {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-username::before {
    content: '👤';
    font-size: 0.9rem;
}

.sidebar-nav ul {
    padding: 1rem 0;
}

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition-base);
}

.sidebar-nav a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav a.active {
    background: var(--accent-gradient);
    color: var(--bg-primary);
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.sidebar-nav .icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
}

.sidebar-nav .logout-link {
    color: var(--danger-color);
}

.sidebar-nav .logout-link:hover {
    background: var(--danger-bg);
    color: var(--danger-color);
}

/* Mobile Menu Toggle for Admin */
.admin-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.admin-menu-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition-base);
}

/* === Admin Content === */
.admin-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    background: var(--bg-primary);
}

.admin-header {
    background: var(--bg-secondary);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.admin-header h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.content-inner {
    padding: 2rem;
}

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

.stat-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
    box-shadow: var(--shadow-lg);
}

.stat-card.stat-primary {
    border-left: 4px solid var(--primary-light);
}

.stat-card.stat-success {
    border-left: 4px solid var(--success-color);
}

.stat-card.stat-info {
    border-left: 4px solid var(--info-color);
}

.stat-card.stat-warning {
    border-left: 4px solid var(--warning-color);
}

.stat-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
}

.stat-details h3 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-details p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.dashboard-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.dashboard-section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 600;
}

.btn-link {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-link:hover {
    text-decoration: underline;
}

/* === Tables === */
.table-responsive {
    overflow-x: auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

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

.data-table thead {
    background: rgba(255, 255, 255, 0.05);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: var(--transition-base);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

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

.table-thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.no-image {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.page-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* === Filter Section === */
.filter-section {
    background: var(--bg-secondary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.filter-form {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-form label {
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-form select {
    padding: 0.6rem 1rem;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
}

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

/* === Forms === */
.form-container {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    max-width: 800px;
}

.admin-form .form-group {
    margin-bottom: 1.5rem;
}

.admin-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.admin-form input,
.admin-form textarea,
.admin-form select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-family: var(--font-primary);
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition-base);
}

.admin-form input:focus,
.admin-form textarea:focus,
.admin-form select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.admin-form input::placeholder,
.admin-form textarea::placeholder {
    color: var(--text-muted);
}

.form-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.current-image {
    margin-bottom: 1rem;
}

.preview-image {
    max-width: 300px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

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

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-base);
    border: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-gradient);
    color: var(--bg-primary);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

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

.btn-success:hover {
    background: #0ea571;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-edit {
    background: var(--info-bg);
    color: var(--info-color);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.btn-edit:hover {
    background: var(--info-color);
    color: white;
}

.btn-delete {
    background: var(--danger-bg);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

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

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* === Alerts === */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.alert ul {
    list-style: disc;
    margin-left: 1.25rem;
}

/* === Empty States === */
.no-data-card,
.no-data {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.no-data {
    padding: 2rem;
}

.no-data-card p,
.no-data p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.no-data a {
    color: var(--accent-color);
}

/* === Page Actions === */
.page-actions {
    margin-bottom: 1.5rem;
}

/* === Actions Column === */
.actions {
    display: flex;
    gap: 0.5rem;
}

/* =============================================
   RESPONSIVE DESIGN
   ============================================= */

/* Tablet */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .admin-menu-toggle {
        display: flex;
    }

    .admin-sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .admin-sidebar.active {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

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

    .admin-header {
        padding: 1rem 1.5rem;
        padding-left: 4rem;
    }

    .admin-header h1 {
        font-size: 1.25rem;
    }

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

    .content-inner {
        padding: 1rem;
    }

    .form-container {
        padding: 1.25rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 2rem;
    }

    .stat-details h3 {
        font-size: 1.5rem;
    }

    .actions {
        flex-direction: column;
        gap: 0.375rem;
    }

    .actions .btn {
        width: 100%;
        justify-content: center;
    }

    .data-table {
        font-size: 0.85rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
    }

    .table-thumbnail {
        width: 40px;
        height: 40px;
    }

    .dashboard-actions {
        flex-direction: column;
    }

    .dashboard-actions .btn {
        width: 100%;
    }

    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-form select {
        width: 100%;
    }

    .login-box {
        padding: 1.5rem;
    }

    .login-container {
        padding: 1rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {

    .btn:hover,
    .stat-card:hover,
    .data-table tbody tr:hover {
        transform: none;
    }

    .sidebar-nav a,
    .btn {
        min-height: 44px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}

/* === Inline Category Creation === */
.category-selection-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.or-divider {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    margin: 5px 0;
}

.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background-color: var(--border-color);
}

.or-divider::before {
    margin-right: 10px;
}

.or-divider::after {
    margin-left: 10px;
}