/* ==========================================================================
   Sistema de Monitoreo - Sembrando Sistemas
   Paleta: Verdes bosque, marrones tierra, oliva
   ========================================================================== */

:root {
    --color-bg: #F0F2F0;
    --color-text: #3D403A;
    --color-header: #3A312A;
    --color-header-text: #EAE7DC;
    --color-sidebar: #2C2418;
    --color-sidebar-hover: #3A5A40;
    --color-sidebar-active: #588157;
    --color-sidebar-text: #D4D1CB;
    --color-sidebar-icon: #A3B18A;
    --color-primary: #588157;
    --color-primary-hover: #3A5A40;
    --color-accent: #6B8E23;
    --color-card: #FFFFFF;
    --color-card-hover: #6B8E23;
    --color-border: #ccd5ae;
    --color-danger: #e63946;
    --color-warning: #f4a261;
    --color-success: #588157;
    --color-info: #457b9d;

    --sidebar-width: 240px;
    --sidebar-collapsed: 60px;
    --topbar-height: 56px;
    --transition: 0.25s ease;
}

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

html, body {
    font-family: 'Segoe UI', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    height: 100%;
}

/* ==========================================================================
   Topbar
   ========================================================================== */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-collapsed);
    right: 0;
    height: var(--topbar-height);
    background-color: var(--color-header);
    color: var(--color-header-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    transition: left var(--transition);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-logo {
    height: 36px;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-header-text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-search {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    padding: 6px 12px;
    color: var(--color-header-text);
    font-size: 0.85rem;
    width: 220px;
    transition: all 0.2s;
}

.topbar-search::placeholder {
    color: rgba(234,231,220,0.5);
}

.topbar-search:focus {
    outline: none;
    background: rgba(255,255,255,0.15);
    border-color: var(--color-accent);
    width: 280px;
}

.topbar-notifications {
    position: relative;
    cursor: pointer;
    font-size: 1.2rem;
}

.notification-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--color-danger);
    color: white;
    border-radius: 50%;
    font-size: 0.65rem;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.topbar-user:hover {
    background: rgba(255,255,255,0.1);
}

.topbar-user-name {
    font-size: 0.85rem;
}

.topbar-user-role {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-collapsed);
    height: 100vh;
    background-color: var(--color-sidebar);
    z-index: 1001;
    transition: width var(--transition);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar:hover,
.sidebar.expanded {
    width: var(--sidebar-width);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--color-sidebar-text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    gap: 12px;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: white;
}

.nav-item.active {
    background: rgba(88,129,87,0.2);
    border-left-color: var(--color-sidebar-active);
    color: white;
}

.nav-icon {
    font-size: 1.1rem;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
    color: var(--color-sidebar-icon);
}

.nav-item.active .nav-icon {
    color: var(--color-accent);
}

.nav-label {
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.sidebar:hover .nav-label,
.sidebar.expanded .nav-label {
    opacity: 1;
}

.nav-section {
    padding: 16px 14px 6px;
    font-size: 0.65rem;
    text-transform: uppercase;
    color: rgba(255,255,255,0.3);
    letter-spacing: 1px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition);
}

.sidebar:hover .nav-section,
.sidebar.expanded .nav-section {
    opacity: 1;
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

/* ==========================================================================
   Main Content
   ========================================================================== */
.main-content {
    margin-left: var(--sidebar-collapsed);
    margin-top: var(--topbar-height);
    padding: 20px;
    min-height: calc(100vh - var(--topbar-height));
    transition: margin-left var(--transition);
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    background: var(--color-card);
    border-radius: 8px;
    padding: 1.2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: all 0.2s;
    text-decoration: none;
    color: var(--color-text);
    border: none;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.card-link {
    display: block;
    text-decoration: none;
    color: var(--color-text);
}

.card-link:hover {
    background-color: var(--color-card-hover);
    color: white;
    transform: translateY(-3px);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-primary {
    background-color: var(--color-primary) !important;
    border: none !important;
    color: white !important;
}

.btn-primary:hover {
    background-color: var(--color-primary-hover) !important;
}

.btn-success {
    background-color: var(--color-success) !important;
    border: none !important;
}

.btn-danger {
    background-color: var(--color-danger) !important;
    border: none !important;
}

.btn-configuracion {
    background-color: #D4A373;
    color: #3A312A;
    border: 1px solid #BC6C25;
}

.btn-configuracion:hover {
    background-color: #BC6C25;
    color: #FEFAE0;
}

/* ==========================================================================
   Alerts
   ========================================================================== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-danger {
    background: #fce4e4;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.alert-info {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-ss {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.table-ss thead {
    background: var(--color-header);
    color: var(--color-header-text);
}

.table-ss th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
}

.table-ss td {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
}

.table-ss tbody tr:hover {
    background: #f8f9f8;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
}

.toast {
    background: var(--color-header);
    color: var(--color-header-text);
    padding: 12px 20px;
    border-radius: 6px;
    margin-top: 8px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s;
    font-size: 0.85rem;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

/* ==========================================================================
   User Dropdown
   ========================================================================== */
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(var(--topbar-height) - 4px);
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    min-width: 180px;
    z-index: 1100;
    overflow: hidden;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown a {
    display: block;
    padding: 10px 16px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.user-dropdown a:hover {
    background: var(--color-bg);
}

/* ==========================================================================
   Modals (Bootstrap Override)
   ========================================================================== */
.modal-content {
    border: none;
    border-radius: 10px;
}

.modal-header {
    background: var(--color-header);
    color: var(--color-header-text);
    border-radius: 10px 10px 0 0;
}

.modal-header .btn-close {
    filter: invert(1);
}

/* ==========================================================================
   KPI Cards (Dashboard)
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-align: center;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.kpi-label {
    font-size: 0.8rem;
    color: #888;
    margin-top: 4px;
}

/* ==========================================================================
   Status Badges
   ========================================================================== */
.badge-ok {
    background: var(--color-success);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.badge-warning {
    background: var(--color-warning);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.badge-critical {
    background: var(--color-danger);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.badge-info {
    background: var(--color-info);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .topbar {
        left: 0;
    }

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

    .topbar-search {
        display: none;
    }

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

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