/* ==========================================================================
   ZARLOP S.A.C. - SGD MODULE STYLES (PREMIUM EDITION)
   ========================================================================== */

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

:root {
    /* Brand Colors */
    --sgd-primary: #0F6CBD;
    --sgd-primary-hover: #0b5394;
    --sgd-primary-light: rgba(15, 108, 189, 0.1);
    
    /* Layout Colors */
    --sgd-bg-app: #F4F7FA;
    --sgd-bg-surface: #FFFFFF;
    --sgd-bg-sidebar: #0B1121; /* Deep slate */
    
    /* Text Colors */
    --sgd-text-main: #1E293B;
    --sgd-text-muted: #64748B;
    --sgd-text-sidebar: #94A3B8;
    --sgd-text-sidebar-hover: #FFFFFF;
    
    /* UI Elements */
    --sgd-border: #E2E8F0;
    --sgd-radius-sm: 6px;
    --sgd-radius-md: 10px;
    --sgd-radius-lg: 16px;
    
    /* Status Colors */
    --sgd-success: #10B981;
    --sgd-success-bg: #D1FAE5;
    --sgd-warning: #F59E0B;
    --sgd-warning-bg: #FEF3C7;
    --sgd-error: #EF4444;
    --sgd-error-bg: #FEE2E2;
    --sgd-info: #3B82F6;
    
    /* Shadows */
    --sgd-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --sgd-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --sgd-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--sgd-bg-app);
    margin: 0;
    padding: 0;
    color: var(--sgd-text-main);
    -webkit-font-smoothing: antialiased;
}

/* --- LOGIN PAGE (PREMIUM) --- */
.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0B1121 0%, #0F6CBD 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.03) 0%, transparent 60%);
    pointer-events: none;
}

.login-card {
    background: var(--sgd-bg-surface);
    padding: 48px;
    border-radius: var(--sgd-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 420px;
    text-align: center;
    border-top: 6px solid var(--sgd-primary);
    position: relative;
    z-index: 10;
}

.login-logo {
    max-width: 200px;
    margin-bottom: 24px;
}

.login-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--sgd-text-main);
    margin: 0 0 8px 0;
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: 0.9rem;
    color: var(--sgd-text-muted);
    margin: 0 0 32px 0;
}

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

.error-message {
    color: var(--sgd-error);
    background: var(--sgd-error-bg);
    padding: 10px;
    border-radius: var(--sgd-radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: left;
    display: none;
}

/* --- APP LAYOUT --- */
.sgd-app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- SIDEBAR (Premium Dark) --- */
.sgd-sidebar {
    width: 260px;
    background: var(--sgd-bg-sidebar);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 10;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo {
    max-width: 160px;
    filter: brightness(0) invert(1); /* Pone el logo blanco si es PNG oscuro */
}

.sidebar-menu {
    flex: 1;
    padding: 24px 12px;
    overflow-y: auto;
}

.menu-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
    font-weight: 700;
    padding: 0 12px;
    margin-bottom: 10px;
    margin-top: 20px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    color: var(--sgd-text-sidebar);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: var(--sgd-radius-sm);
    transition: all 0.2s ease;
    gap: 12px;
    margin-bottom: 4px;
}

.menu-item svg {
    opacity: 0.7;
    transition: opacity 0.2s;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--sgd-text-sidebar-hover);
}

.menu-item:hover svg {
    opacity: 1;
}

.menu-item.active {
    background: var(--sgd-primary);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(15, 108, 189, 0.4);
}

.menu-item.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
}

.user-info {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #FFFFFF;
}

.user-role {
    font-size: 0.75rem;
    color: var(--sgd-text-sidebar);
}

.btn-logout {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--sgd-radius-sm);
    color: var(--sgd-text-sidebar);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #FCA5A5;
    border-color: rgba(239, 68, 68, 0.3);
}

/* --- MAIN CONTENT & TOPBAR --- */
.sgd-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sgd-topbar {
    height: 70px;
    background: var(--sgd-bg-surface);
    border-bottom: 1px solid var(--sgd-border);
    display: flex;
    align-items: center;
    padding: 0 32px;
    box-shadow: var(--sgd-shadow-sm);
    z-index: 5;
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--sgd-text-main);
    letter-spacing: -0.01em;
    margin: 0;
}

.sgd-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* --- UI COMPONENTS --- */
.card {
    background: var(--sgd-bg-surface);
    border-radius: var(--sgd-radius-md);
    border: 1px solid var(--sgd-border);
    padding: 24px;
    box-shadow: var(--sgd-shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--sgd-shadow-md);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--sgd-primary);
    color: white;
    border: none;
    border-radius: var(--sgd-radius-sm);
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(15, 108, 189, 0.2);
}

.btn-primary:hover {
    background-color: var(--sgd-primary-hover);
    box-shadow: 0 4px 8px rgba(15, 108, 189, 0.3);
    transform: translateY(-1px);
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--sgd-border);
    color: var(--sgd-text-main);
    padding: 10px 18px;
    border-radius: var(--sgd-radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: #F8FAFC;
    border-color: #CBD5E1;
}

/* --- BADGES --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-pending { background: var(--sgd-warning-bg); color: #B45309; }
.status-reviewed { background: #E0F2FE; color: #0369A1; }
.status-sent { background: #EDE9FE; color: #5B21B6; }
.status-approved { background: var(--sgd-success-bg); color: #047857; }
.status-draft { background: #F1F5F9; color: #475569; }

/* --- DATA TABLES --- */
.table-container {
    background: var(--sgd-bg-surface);
    border-radius: var(--sgd-radius-md);
    border: 1px solid var(--sgd-border);
    box-shadow: var(--sgd-shadow-sm);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--sgd-border);
    font-size: 0.9rem;
}

th {
    background: #F8FAFC;
    font-weight: 600;
    color: var(--sgd-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 2;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #F8FAFC; }

/* --- FORMS --- */
.form-section {
    background: var(--sgd-bg-surface);
    padding: 28px;
    border-radius: var(--sgd-radius-md);
    border: 1px solid var(--sgd-border);
    box-shadow: var(--sgd-shadow-sm);
    margin-bottom: 24px;
}

.form-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--sgd-text-main);
    margin-top: 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--sgd-border);
    padding-bottom: 12px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--sgd-text-muted);
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--sgd-border);
    border-radius: var(--sgd-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--sgd-text-main);
    background: #F8FAFC;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    background: white;
    border-color: var(--sgd-primary);
    box-shadow: 0 0 0 3px var(--sgd-primary-light);
}

/* Items Table overrides for inputs */
.items-table input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 0.9rem;
}
.items-table input:focus { border-color: var(--sgd-primary); outline:none; }

.summary-panel {
    background: #F8FAFC;
    border: 1px solid var(--sgd-border);
    padding: 24px;
    border-radius: var(--sgd-radius-md);
    width: 320px;
    box-shadow: var(--sgd-shadow-sm);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--sgd-text-muted);
}

.summary-row span:last-child {
    font-weight: 600;
    color: var(--sgd-text-main);
}

.summary-row.total {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--sgd-primary);
    border-top: 2px solid var(--sgd-border);
    padding-top: 14px;
    margin-top: 14px;
}
.summary-row.total span:last-child { color: var(--sgd-primary); }

.summary-row.profit { color: var(--sgd-success); font-weight: 600; }
.summary-row.profit span:last-child { color: var(--sgd-success); }


/* ================== AUTOCOMPLETE & MODALS ================== */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--sgd-surface, #ffffff);
    border: 1px solid var(--sgd-border);
    border-radius: var(--sgd-radius-sm);
    box-shadow: var(--sgd-shadow-md);
    margin-top: 4px;
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
    display: none;
}
.autocomplete-item {
    padding: 10px 15px;
    border-bottom: 1px solid var(--sgd-border);
    cursor: pointer;
    transition: background 0.2s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #f1f5f9; }
.autocomplete-title { font-weight: 600; font-size: 0.875rem; color: var(--sgd-text-main); margin-bottom: 2px; }
.autocomplete-sub { font-size: 0.75rem; color: var(--sgd-text-muted); }
.autocomplete-empty { padding: 10px 15px; font-size: 0.875rem; color: var(--sgd-text-muted); font-style: italic; text-align: center; }
.autocomplete-action { padding: 10px 15px; font-size: 0.875rem; color: var(--sgd-primary); font-weight: 600; text-align: center; cursor: pointer; border-top: 1px solid var(--sgd-border); background: #f8fafc; }
.autocomplete-action:hover { background: #eff6ff; }

.sgd-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center; justify-content: center;
}
.sgd-modal.active { display: flex; }
.sgd-modal-content {
    background: var(--sgd-bg-surface);
    width: 90%; max-width: 500px;
    border-radius: var(--sgd-radius-md);
    box-shadow: var(--sgd-shadow-lg);
    overflow: hidden;
    animation: modalIn 0.3s ease-out;
}
@keyframes modalIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sgd-modal-header {
    padding: 20px; border-bottom: 1px solid var(--sgd-border);
    display: flex; justify-content: space-between; align-items: center;
}
.sgd-modal-close {
    background: none; border: none; font-size: 1.5rem; color: var(--sgd-text-muted); cursor: pointer; line-height: 1;
}
.sgd-modal-close:hover { color: var(--sgd-error); }
.sgd-modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-list-container {
    border: 1px solid var(--sgd-border); border-radius: var(--sgd-radius-sm);
    max-height: 200px; overflow-y: auto; margin-top: 15px;
}
.modal-list-item {
    padding: 12px; border-bottom: 1px solid var(--sgd-border); cursor: pointer;
}
.modal-list-item:hover { background: #f8fafc; }
.modal-list-item:last-child { border-bottom: none; }
