/* Topbar - Barra superior horizontal */

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 1000;
    border-bottom: 1px solid #e0e0e0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-green);
    text-decoration: none;
}

.topbar-logo svg {
    width: 32px;
    height: 32px;
}

.topbar-center {
    flex: 1;
    max-width: 600px;
    margin: 0 2rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Buscador Global */
.global-search {
    position: relative;
    width: 100%;
}

.global-search input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.global-search input:focus {
    outline: none;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(42, 172, 162, 0.1);
}

.global-search-icon {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

.search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.search-results.active {
    display: block;
}

.search-category {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #666;
    background: #f5f5f5;
    border-top: 1px solid #eee;
}

.search-category:first-child {
    border-top: none;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

.search-result-item:hover,
.search-result-item.selected {
    background: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-icon {
    font-size: 1.2rem;
}

.search-result-text {
    flex: 1;
}

.search-result-title {
    font-weight: 500;
    color: #333;
}

.search-result-subtitle {
    font-size: 0.8rem;
    color: #999;
}

/* Notificaciones */
.notifications-bell {
    position: relative;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s;
}

.notifications-bell:hover {
    background: rgba(0, 0, 0, 0.05);
}

.notifications-bell svg {
    width: 24px;
    height: 24px;
    color: #666;
}

.notifications-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.notifications-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 360px;
    max-height: 500px;
    overflow: hidden;
    display: none;
}

.notifications-dropdown.active {
    display: block;
}

.notifications-header {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notifications-header h3 {
    margin: 0;
    font-size: 1rem;
}

.notifications-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.notification-item:hover {
    background: #f8f9fa;
}

.notification-item.unread {
    background: #e8f5f9;
}

.notification-content {
    font-size: 0.9rem;
    color: #333;
}

.notification-time {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.25rem;
}

/* Toggle Tema */
.theme-toggle {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s;
    font-size: 1.3rem;
}

.theme-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Perfil de Usuario */
.user-profile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: background 0.2s;
}

.user-profile:hover {
    background: rgba(0, 0, 0, 0.05);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: #333;
}

.user-role {
    font-size: 0.75rem;
    color: #999;
}

.user-dropdown-arrow {
    font-size: 0.8rem;
    color: #999;
}

/* Dropdown del Usuario */
.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 200px;
    overflow: hidden;
    display: none;
}

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

.user-dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
}

.user-dropdown-item:hover {
    background: #f8f9fa;
}

.user-dropdown-item.logout {
    color: #e74c3c;
    border-top: 1px solid #eee;
}

/* Ajustes para el contenido principal */
body.has-topbar {
    padding-top: 60px;
}

body.has-topbar .sidebar {
    top: 60px;
    height: calc(100vh - 60px);
}

body.has-topbar .main-content {
    margin-top: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .topbar {
        padding: 0 1rem;
    }

    .topbar-center {
        display: none;
    }

    .user-info {
        display: none;
    }

    .notifications-dropdown,
    .user-dropdown {
        right: -1rem;
    }
}