/**
 * Terzon Admin Panel CSS
 * Supports automatic theme switching (light 7AM-7PM, dark 7PM-7AM)
 */

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f9f9f9;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

body.dark {
    background-color: #1a1a1a;
    color: #f5f5f5;
}

/* Admin Header */
.admin-header {
    height: 60px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

body.dark .admin-header {
    background-color: #2d2d2d;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.logo {
    display: flex;
    align-items: center;
}

.logo a {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    text-decoration: none;
}

body.dark .logo a {
    color: #f5f5f5;
}

.admin-badge {
    margin-left: 10px;
    background-color: #3498db;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.primary-btn, .secondary-btn, .danger-btn, .action-btn {
    padding: 8px 15px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    border: none;
    font-size: 14px;
}

.primary-btn {
    background-color: #3498db;
    color: white;
}

.primary-btn:hover {
    background-color: #2980b9;
}

body.dark .primary-btn {
    background-color: #2980b9;
}

body.dark .primary-btn:hover {
    background-color: #3498db;
}

.secondary-btn {
    background-color: #f1f1f1;
    color: #333;
}

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

body.dark .secondary-btn {
    background-color: #444;
    color: #f5f5f5;
}

body.dark .secondary-btn:hover {
    background-color: #555;
}

.danger-btn {
    background-color: #e74c3c;
    color: white;
}

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

.action-btn {
    background-color: #3498db;
    color: white;
    width: 100%;
    justify-content: center;
    margin-bottom: 15px;
}

.action-btn:hover {
    background-color: #2980b9;
}

body.dark .action-btn {
    background-color: #2980b9;
}

body.dark .action-btn:hover {
    background-color: #3498db;
}

/* Admin Container */
.admin-container {
    display: flex;
    height: calc(100vh - 60px);
}

/* Sidebar */
.admin-sidebar {
    width: 280px;
    background-color: #fff;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    padding: 20px;
    height: 100%;
    overflow-y: auto;
}

body.dark .admin-sidebar {
    background-color: #2d2d2d;
    box-shadow: 2px 0 5px rgba(0,0,0,0.15);
}

.admin-sidebar h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}

body.dark .admin-sidebar h3 {
    color: #f5f5f5;
}

.product-filter {
    margin-bottom: 15px;
}

.product-filter input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

body.dark .product-filter input {
    background-color: #3d3d3d;
    border-color: #555;
    color: #f5f5f5;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-item {
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.product-item:hover {
    background-color: #f1f1f1;
}

body.dark .product-item:hover {
    background-color: #3d3d3d;
}

.product-item.active {
    background-color: #e6f3fa;
    border-left: 3px solid #3498db;
}

body.dark .product-item.active {
    background-color: #2c3e50;
    border-left: 3px solid #3498db;
}

.product-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 10px;
}

.product-item-info {
    flex: 1;
}

.product-item-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

body.dark .product-item-name {
    color: #f5f5f5;
}

.product-item-price {
    color: #e74c3c;
    font-size: 12px;
    font-weight: 600;
}

body.dark .product-item-price {
    color: #ff7675;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #777;
}

body.dark .loading {
    color: #aaa;
}

/* Main Content Area */
.admin-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-screen i {
    font-size: 64px;
    color: #3498db;
    margin-bottom: 20px;
}

body.dark .welcome-screen i {
    color: #2980b9;
}

.welcome-screen h2 {
    font-size: 28px;
    margin-bottom: 10px;
    color: #333;
}

body.dark .welcome-screen h2 {
    color: #f5f5f5;
}

.welcome-screen p {
    margin-bottom: 20px;
    color: #666;
    max-width: 500px;
}

body.dark .welcome-screen p {
    color: #bbb;
}

/* Form Styles */
.product-form-container {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 25px;
    max-width: 900px;
    margin: 0 auto;
}

body.dark .product-form-container {
    background-color: #2d2d2d;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.product-form-container h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 24px;
}

body.dark .product-form-container h2 {
    color: #f5f5f5;
}

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

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #444;
}

body.dark label {
    color: #ddd;
}

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background-color: #fff;
    color: #333;
    font-family: inherit;
}

body.dark input[type="text"],
body.dark input[type="number"],
body.dark textarea,
body.dark select {
    background-color: #3d3d3d;
    border-color: #555;
    color: #f5f5f5;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.help-text {
    font-size: 12px;
    color: #777;
    margin-top: 5px;
}

body.dark .help-text {
    color: #aaa;
}

.checkbox-group {
    display: flex;
    gap: 20px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
}

.form-actions .danger-btn {
    margin-left: auto;
}

/* Additional Images Styling */
.additional-images {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.image-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.image-input-row input {
    flex: 1;
}

.clear-btn {
    background: #f1f1f1;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: #e0e0e0;
    color: #e74c3c;
}

body.dark .clear-btn {
    background: #444;
    color: #aaa;
}

body.dark .clear-btn:hover {
    background: #555;
    color: #e74c3c;
}

/* File Upload Styling */
.image-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.file-upload-wrapper {
    position: relative;
}

.file-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    background-color: #f1f1f1;
    color: #333;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.file-upload-btn:hover {
    background-color: #e0e0e0;
}

body.dark .file-upload-btn {
    background-color: #444;
    color: #f5f5f5;
}

body.dark .file-upload-btn:hover {
    background-color: #555;
}

.file-upload-input {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

/* Image preview */
.image-preview {
    margin-top: 10px;
    max-width: 200px;
    max-height: 200px;
    border-radius: 4px;
    border: 1px solid #ddd;
    overflow: hidden;
}

body.dark .image-preview {
    border-color: #444;
}

.image-preview img {
    width: 100%;
    height: auto;
    display: block;
}

/* 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-content {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    padding: 25px;
    width: 400px;
    max-width: 90%;
}

body.dark .modal-content {
    background-color: #2d2d2d;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.modal h3 {
    margin-bottom: 15px;
    color: #333;
}

body.dark .modal h3 {
    color: #f5f5f5;
}

.modal p {
    margin-bottom: 20px;
    color: #666;
}

body.dark .modal p {
    color: #bbb;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .admin-container {
        flex-direction: column;
        height: auto;
    }
    
    .admin-sidebar {
        width: 100%;
        height: auto;
        max-height: 300px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-actions button {
        width: 100%;
    }
}

/* Sidebar and layout styles (match dashboard) */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 250px;
    background-color: #343a40;
    padding-top: 20px;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid #495057;
}

.sidebar-brand {
    color: white;
    font-size: 20px;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.sidebar-brand span { color: #3f51b5; }

.sidebar-menu { padding: 20px 0; }

.sidebar-menu-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-menu-item:hover,
.sidebar-menu-item.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-menu-item i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.main-content {
    margin-left: 250px;
    padding: 20px;
}

@media (max-width: 768px) {
    .sidebar { width: 70px; }
    .sidebar-brand span,
    .sidebar-menu-item span { display: none; }
    .sidebar-menu-item { justify-content: center; padding: 15px; }
    .sidebar-menu-item i { margin-right: 0; }
    .main-content { margin-left: 70px; }
}

/* =====================================================
   Shared Theme Toggle (light-mode / dark-mode)
   Applies across all admin pages using body classes
   ===================================================== */
/* Light mode base: soft gray background and dark text */
body.light-mode {
    background-color: #f0f2f5;
    color: #111111;
}

/* Also recognize body.dark from older pages */
body.dark-mode,
body.dark {
    background-color: #121212;
    color: #ffffff;
}

/* Light-mode overrides (ensure comfortable contrast, avoid pure white) */
body.light-mode .main-content { background-color: #f0f2f5; }
body.light-mode .filter-bar,
body.light-mode .product-card { background-color: #f3f4f6; color: #111111; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
body.light-mode .search-box input { background-color: #ffffff; border-color: #d1d5db; color: #111111; }
body.light-mode .product-category { background-color: #e5e7eb; color: #111111; }
body.light-mode .edit-btn { background-color: #e5e7eb; color: #111111; }
body.light-mode .edit-btn:hover { background-color: #d8dde3; }
body.light-mode .delete-btn { background-color: #fde2e2; color: #7a1a1a; }
body.light-mode .delete-btn:hover { background-color: #fbcdcd; }
body.light-mode .page-link { background-color: #f3f4f6; border-color: #e5e7eb; color: #111111; }
body.light-mode .page-item.disabled .page-link { background-color: #e5e7eb; border-color: #d1d5db; color: #9ca3af; }

/* Light default when no JS toggle (no .light-mode/.dark-mode class) */
body:not(.dark-mode):not(.dark) .main-content { background-color: #f0f2f5; }
body:not(.dark-mode):not(.dark) .filter-bar,
body:not(.dark-mode):not(.dark) .product-card { background-color: #f3f4f6; color: #111111; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
body:not(.dark-mode):not(.dark) .search-box input { background-color: #ffffff; border-color: #d1d5db; color: #111111; }
body:not(.dark-mode):not(.dark) .product-category { background-color: #e5e7eb; color: #111111; }
body:not(.dark-mode):not(.dark) .edit-btn { background-color: #e5e7eb; color: #111111; }
body:not(.dark-mode):not(.dark) .edit-btn:hover { background-color: #d8dde3; }
body:not(.dark-mode):not(.dark) .delete-btn { background-color: #fde2e2; color: #7a1a1a; }
body:not(.dark-mode):not(.dark) .page-link { background-color: #f3f4f6; border-color: #e5e7eb; color: #111111; }

/* ============================================
   DARK MODE - Enhanced Visibility
   ============================================ */

/* Sidebar - Dark gradient background */
body.dark-mode .sidebar,
body.dark .sidebar { 
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-right: 1px solid rgba(148, 163, 184, 0.1);
}

body.dark-mode .sidebar-brand,
body.dark .sidebar-brand { color: #f8fafc; }

body.dark-mode .sidebar-brand span,
body.dark .sidebar-brand span { color: #a5b4fc; }

body.dark-mode .sidebar-menu-item,
body.dark .sidebar-menu-item { color: #cbd5e1; }

body.dark-mode .sidebar-menu-item:hover,
body.dark .sidebar-menu-item:hover,
body.dark-mode .sidebar-menu-item.active,
body.dark .sidebar-menu-item.active { 
    background: rgba(99, 102, 241, 0.2); 
    color: #a5b4fc;
}

/* Filter bar and product cards */
body.dark-mode .filter-bar,
body.dark .filter-bar,
body.dark-mode .product-card,
body.dark .product-card { 
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    color: #f1f5f9; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

body.dark-mode .product-category,
body.dark .product-category { 
    background-color: rgba(99, 102, 241, 0.2); 
    color: #a5b4fc; 
}

/* Buttons */
body.dark-mode .edit-btn,
body.dark .edit-btn { 
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: #fff;
    border: none;
}

body.dark-mode .edit-btn:hover,
body.dark .edit-btn:hover { 
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
}

body.dark-mode .delete-btn,
body.dark .delete-btn { 
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #fff;
}

body.dark-mode .delete-btn:hover,
body.dark .delete-btn:hover {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}

/* Pagination */
body.dark-mode .page-link,
body.dark .page-link { 
    background-color: #1e293b; 
    border-color: #334155; 
    color: #e2e8f0; 
}

body.dark-mode .page-link:hover,
body.dark .page-link:hover {
    background-color: #334155;
    color: #f8fafc;
}

/* Search box */
body.dark-mode .search-box input,
body.dark .search-box input {
    background-color: #1e293b;
    border: 2px solid #334155;
    color: #f1f5f9;
}

body.dark-mode .search-box input:focus,
body.dark .search-box input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

body.dark-mode .search-box input::placeholder,
body.dark .search-box input::placeholder {
    color: #64748b;
}

/* Tables */
body.dark-mode table,
body.dark table {
    background: #1e293b;
    color: #f1f5f9;
}

body.dark-mode th,
body.dark th {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
}

body.dark-mode td,
body.dark td {
    border-color: #334155;
}

body.dark-mode tr:hover,
body.dark tr:hover {
    background: rgba(99, 102, 241, 0.1);
}

/* Modals */
body.dark-mode .modal-content,
body.dark .modal-content {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(148, 163, 184, 0.15);
    color: #f1f5f9;
}

body.dark-mode .modal-header,
body.dark .modal-header {
    border-color: #334155;
}

body.dark-mode .modal-footer,
body.dark .modal-footer {
    border-color: #334155;
}

/* Alerts */
body.dark-mode .alert,
body.dark .alert {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-mode .alert-success,
body.dark .alert-success {
    background: linear-gradient(135deg, #065f46 0%, #047857 100%);
    border-color: #10b981;
    color: #d1fae5;
}

body.dark-mode .alert-danger,
body.dark .alert-danger {
    background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%);
    border-color: #dc2626;
    color: #fecaca;
}

/* Form controls */
body.dark-mode .form-control,
body.dark .form-control {
    background-color: #1e293b;
    border: 2px solid #334155;
    color: #f1f5f9;
}

body.dark-mode .form-control:focus,
body.dark .form-control:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
    background-color: #1e293b;
}

/* Cards */
body.dark-mode .card,
body.dark .card {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(148, 163, 184, 0.15);
}

body.dark-mode .card-header,
body.dark .card-header {
    background: rgba(15, 23, 42, 0.5);
    border-color: #334155;
    color: #f8fafc;
}

body.dark-mode .card-body,
body.dark .card-body {
    color: #e2e8f0;
}
