:root {
    /* Corporate Palette */
    --primary-color: #0f172a; /* Slate 900 */
    --primary-light: #334155;
    --accent-color: #2563eb; /* Blue 600 */
    --accent-hover: #1d4ed8;
    
    --success-bg: #dcfce7; --success-text: #166534;
    --warning-bg: #fef9c3; --warning-text: #854d0e;
    --danger-bg: #fee2e2; --danger-text: #991b1b;
    --info-bg: #e0f2fe; --info-text: #075985;
    
    --bg-body: #f1f5f9; /* Slate 100 */
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    
    --sidebar-width: 260px;
    --header-height: 64px;
}

/* Reset & Typography */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; }

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 600; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-muted { color: var(--text-muted); }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mr-2 { margin-right: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-4 { gap: 1rem; }
.gap-2 { gap: 0.5rem; }
.grid { display: grid; }
.w-full { width: 100%; }
.h-screen { height: 100vh; }

.hidden { display: none !important; }

/* Layout */
.wrapper { display: flex; width: 100%; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-color);
    color: #cbd5e1;
    position: fixed;
    height: 100%;
    z-index: 100;
    transition: all 0.3s;
    box-shadow: 4px 0 24px rgba(0,0,0,0.05);
    overflow-y: auto; /* Fix scrolling */
}
.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar ul { padding: 1rem 0; }
.sidebar ul li a {
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    font-weight: 500;
    border-left: 3px solid transparent;
}
.sidebar ul li a:hover, .sidebar ul li a.active {
    background: rgba(255,255,255,0.05);
    color: #fff;
    border-left-color: var(--accent-color);
}
.sidebar ul li a i { width: 24px; text-align: center; margin-right: 12px; opacity: 0.8; }

/* Content Area */
.content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: all 0.3s;
}

.top-navbar {
    height: var(--header-height);
    background: #fff;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.main-content { padding: 2rem; max-width: 1400px; margin: 0 auto; }

/* Responsive Sidebar */
@media (max-width: 768px) {
    .sidebar { margin-left: calc(var(--sidebar-width) * -1); }
    .sidebar.active { margin-left: 0; }
    .content { margin-left: 0; width: 100%; }
    .overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }
    .overlay.active { display: block; }
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}
.card:hover { box-shadow: 0 4px 6px rgba(0,0,0,0.05); }

/* Dashboard KPI Cards specialized */
.kpi-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kpi-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
}
.bg-blue-100 { background-color: #dbeafe; color: #1e40af; }
.bg-green-100 { background-color: #dcfce7; color: #166534; }
.bg-yellow-100 { background-color: #fef9c3; color: #854d0e; }
.bg-red-100 { background-color: #fee2e2; color: #991b1b; }

/* Grid Layouts */
.grid-container { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); 
    gap: 1.5rem; 
}
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
@media(max-width: 768px) { .grid-cols-2 { grid-template-columns: 1fr; } }

/* Catalog Management Specifics */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr); /* Mobile: 1 col */
    gap: 1.5rem;
}
@media (min-width: 640px) {
    .catalog-grid { grid-template-columns: repeat(2, 1fr); } /* Tablet: 2 col */
}
@media (min-width: 1024px) {
    .catalog-grid { grid-template-columns: repeat(3, 1fr); } /* Desktop: 3 col */
}
@media (min-width: 1280px) {
    .catalog-grid { grid-template-columns: repeat(4, 1fr); } /* Large Desktop: 4 col */
}

.catalog-card {
    display: flex;
    flex-direction: column;
    height: 320px; /* Fixed visual height */
    padding: 0; /* Override default padding */
    overflow: hidden;
}

.catalog-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: #fcfcfc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.catalog-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
}

.catalog-count {
    background-color: var(--bg-body);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    font-weight: 500;
}

.catalog-body {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background-color: #fff;
}

/* Custom Scrollbar for Catalog Body */
.catalog-body::-webkit-scrollbar { width: 6px; }
.catalog-body::-webkit-scrollbar-track { background: transparent; }
.catalog-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.catalog-body::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.catalog-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.catalog-item {
    padding: 0.5rem 0.75rem;
    background-color: #f8fafc;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 0.875rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    transition: all 0.2s;
}
.catalog-item:hover {
    background-color: #fff;
    border-color: var(--accent-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    color: var(--accent-color);
}
.catalog-item i { font-size: 0.5rem; color: #cbd5e1; margin-right: 0.75rem; }
.catalog-item:hover i { color: var(--accent-color); }

.catalog-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
}

.btn-add {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    background-color: var(--bg-body);
    color: var(--accent-color);
    border: 1px solid transparent;
}
.btn-add:hover {
    background-color: var(--accent-color);
    color: white;
}

/* Tables */
.table-responsive { overflow-x: auto; border-radius: 0.5rem; border: 1px solid var(--border-color); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th { 
    text-align: left; 
    padding: 1rem; 
    background: #f8fafc; 
    color: var(--text-muted); 
    font-weight: 600; 
    font-size: 0.8rem; 
    text-transform: uppercase; 
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}
td { 
    padding: 1rem; 
    border-bottom: 1px solid var(--border-color); 
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background-color: #f8fafc; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }

/* Buttons */
button, .btn, a[class*="bg-"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border-radius: 0.375rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    text-align: center;
}
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

.bg-blue-500, .bg-blue-600, .bg-indigo-600 { background: var(--accent-color); color: white; }
.bg-blue-500:hover, .bg-indigo-600:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(37,99,235,0.2); }

.bg-gray-500, .bg-gray-600 { background: #64748b; color: white; }
.bg-gray-500:hover { background: #475569; }

.bg-green-500, .bg-green-600 { background: #22c55e; color: white; }
.bg-green-500:hover { background: #16a34a; }

.bg-red-500 { background: #ef4444; color: white; }
.bg-red-500:hover { background: #dc2626; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; color: var(--text-main); }
.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.95rem;
    transition: 0.2s;
    background: #fff;
    color: var(--text-main);
}
.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-control:disabled { background: #f1f5f9; color: var(--text-muted); cursor: not-allowed; }

/* Modal (Deprecated: Bootstrap uses .modal) */
.modal { display: none; position: fixed; z-index: 1000; inset: 0; background-color: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); overflow-y: auto; }

/* Custom Modal with Transitions */
.custom-modal {
    display: block; /* Hidden via opacity/visibility */
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    overflow-y: auto;

    /* Transition Properties */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.custom-modal.show {
    opacity: 1;
    visibility: visible;
}

/* Base Modal Content (Legacy) */
.modal-content {
    background-color: #fff;
    margin: 5vh auto;
    padding: 2rem;
    border-radius: 1rem;
    width: 95%;
    max-width: 600px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
}

.custom-modal .modal-content {
    /* Transform Transition */
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.custom-modal.show .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}
.close { position: absolute; top: 1.5rem; right: 1.5rem; font-size: 1.5rem; color: var(--text-muted); transition: 0.2s; }
.close:hover { color: var(--text-main); transform: rotate(90deg); }

/* Modern Modal Styles (Global) */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal-box { background: #fff; border-radius: 16px; width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); padding: 0; animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid #f3f4f6; display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 1.125rem; font-weight: 700; color: #111827; }
.modal-close { background: none; border: none; font-size: 1.5rem; color: #9ca3af; cursor: pointer; line-height: 1; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; background: #f9fafb; border-top: 1px solid #f3f4f6; display: flex; justify-content: flex-end; gap: 12px; }
@keyframes modalSlide { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Tabs - Profile */
.tabs-nav { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 1.5rem; overflow-x: auto; }
.tabs-nav button {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.tabs-nav button:hover { color: var(--accent-color); }
.tabs-nav button.active { color: var(--accent-color); border-bottom-color: var(--accent-color); }

/* Profile Header */
.profile-header { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 2rem; }
.profile-avatar { 
    width: 80px; height: 80px; 
    background: var(--accent-color); color: white; 
    font-size: 2.5rem; font-weight: bold; 
    border-radius: 50%; 
    display: flex; align-items: center; justify-content: center;
}

/* =========================================
   Login Page Redesign (CSS Only Override)
   ========================================= */

/* 1. Page Background - Softer Tone & Pattern */
body.bg-gray-100.flex.items-center.justify-center.h-screen {
    background-color: #f1f5f9;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 24px 24px;
}

/* 2. Main Card Container Transformation */
/* Target specific structure: body class + card classes */
body.bg-gray-100 > div.bg-white.rounded.shadow-md.w-full.max-w-sm {
    /* Layout & Size */
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: min-content;
    align-content: center;

    width: 900px !important;
    max-width: 90% !important;
    min-height: 550px;
    padding: 0 !important; /* Remove default padding to control layout */

    border-radius: 16px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
    overflow: hidden;

    /* Right Side Background (Default for the container) */
    background-color: var(--accent-color) !important;
    color: white !important;
}

/* 3. Left Column - Illustration (Pseudo-element) */
body.bg-gray-100 > div.bg-white.w-full.max-w-sm::before {
    content: "";
    grid-column: 1;
    grid-row: 1 / 10; /* Span all rows */
    background-color: #ffffff;
    background-image: url('../img/candado.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 50%;
    border-right: 1px solid rgba(0,0,0,0.05);
}

/* 4. Right Column Content - Text & Forms */
body.bg-gray-100 > div.bg-white.w-full.max-w-sm > * {
    grid-column: 2;
    margin-left: 3rem !important;
    margin-right: 3rem !important;
    position: relative;
    z-index: 2;
}

/* Specific Adjustments for Children */

/* Heading */
body.bg-gray-100 > div.bg-white.w-full.max-w-sm h2 {
    color: #ffffff !important;
    text-align: left !important;
    font-size: 2rem !important;
    margin-bottom: 2rem !important;
    font-weight: 800 !important;
    margin-top: 2rem !important;
}
body.bg-gray-100 > div.bg-white.w-full.max-w-sm h2::after {
    content: "Welcome Back";
    display: block;
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.8;
    margin-top: 0.25rem;
}

/* Labels */
body.bg-gray-100 > div.bg-white.w-full.max-w-sm label {
    color: rgba(255,255,255,0.9) !important;
    font-weight: 500 !important;
    font-size: 0.85rem !important;
    margin-bottom: 0.5rem !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Inputs */
body.bg-gray-100 > div.bg-white.w-full.max-w-sm input {
    background-color: #ffffff !important;
    border: 2px solid transparent !important;
    color: #0f172a !important; /* Dark text */
    border-radius: 8px !important;
    padding: 0.75rem 1rem !important;
    margin-bottom: 1.5rem !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}
body.bg-gray-100 > div.bg-white.w-full.max-w-sm input:focus {
    box-shadow: 0 0 0 4px rgba(255,255,255,0.2) !important;
    border-color: rgba(255,255,255,0.5) !important;
    outline: none !important;
}

/* Button */
body.bg-gray-100 > div.bg-white.w-full.max-w-sm button {
    background-color: #0f172a !important; /* Dark Slate / Navy */
    color: #ffffff !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem !important;
    border-radius: 8px !important;
    margin-top: 0.5rem !important;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
    transition: transform 0.2s, background-color 0.2s !important;
}
body.bg-gray-100 > div.bg-white.w-full.max-w-sm button:hover {
    background-color: #1e293b !important;
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1) !important;
}

/* Footer Link */
body.bg-gray-100 > div.bg-white.w-full.max-w-sm p {
    color: rgba(255,255,255,0.6) !important;
    margin-top: 2rem !important;
    text-align: center;
    margin-bottom: 2rem !important;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body.bg-gray-100 > div.bg-white.w-full.max-w-sm {
        grid-template-columns: 1fr !important;
        width: 100% !important;
        max-width: 400px !important;
        background-color: #ffffff !important; /* Revert to white card on mobile */
        color: inherit !important;
    }

    /* Hide Illustration */
    body.bg-gray-100 > div.bg-white.w-full.max-w-sm::before {
        display: none !important;
    }

    /* Revert text colors for white background */
    body.bg-gray-100 > div.bg-white.w-full.max-w-sm > * {
        grid-column: 1 !important;
        margin-left: 2rem !important;
        margin-right: 2rem !important;
    }

    body.bg-gray-100 > div.bg-white.w-full.max-w-sm h2 {
        color: #1e293b !important;
        text-align: center !important;
    }
    body.bg-gray-100 > div.bg-white.w-full.max-w-sm h2::after {
        color: #64748b;
    }

    body.bg-gray-100 > div.bg-white.w-full.max-w-sm label {
        color: #475569 !important;
    }

    body.bg-gray-100 > div.bg-white.w-full.max-w-sm input {
        border: 1px solid #e2e8f0 !important;
        background-color: #f8fafc !important;
    }

    body.bg-gray-100 > div.bg-white.w-full.max-w-sm button {
        background-color: var(--accent-color) !important; /* Blue button on white */
    }

    body.bg-gray-100 > div.bg-white.w-full.max-w-sm p {
        color: #94a3b8 !important;
    }
}
.justify-center { justify-content: center; }
