/**
 * DENTIFY - Componentes CSS
 * Layout, Sidebar, Botones, Formularios, Cards, Modales, etc.
 */

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-normal);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.page-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    padding: var(--space-4) var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
}

.page-content {
    flex: 1;
    padding: var(--space-6);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    z-index: var(--z-fixed);
    transition: width var(--transition-normal);
    overflow: hidden;
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--text-xl);
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    white-space: nowrap;
}

.sidebar-collapsed .sidebar-logo-text {
    display: none;
}

.sidebar-toggle {
    margin-left: auto;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.sidebar-user {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--primary-100);
    color: var(--primary-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-semibold);
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-name {
    font-weight: var(--font-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.sidebar-collapsed .sidebar-user-info {
    display: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) 0;
}

.sidebar-section {
    margin-bottom: var(--space-4);
}

.sidebar-section-title {
    padding: var(--space-2) var(--space-5);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-collapsed .sidebar-section-title {
    display: none;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: 0 var(--space-3);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.sidebar-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-item.active {
    background: var(--primary-50);
    color: var(--primary-600);
}

.sidebar-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-collapsed .sidebar-item-text {
    display: none;
}

.sidebar-item-badge {
    padding: var(--space-1) var(--space-2);
    background: var(--error-500);
    color: white;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

.sidebar-collapsed .sidebar-item {
    position: relative;
    justify-content: center;
}

.sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--border-light);
}

.sidebar-upgrade {
    background: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    color: white;
    margin: var(--space-3);
}

.sidebar-upgrade-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.sidebar-upgrade-title {
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-2);
}

.sidebar-upgrade-text {
    font-size: var(--text-sm);
    opacity: 0.9;
    margin-bottom: var(--space-3);
}

.sidebar-upgrade-btn {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-4);
    background: white;
    color: var(--primary-600);
    text-align: center;
    border-radius: var(--radius-lg);
    font-weight: var(--font-medium);
}

.sidebar-upgrade-btn:hover {
    background: var(--gray-100);
    color: var(--primary-700);
}

.sidebar-collapsed .sidebar-upgrade {
    display: none;
}

/* ============================================
   BOTONES
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-weight: var(--font-medium);
    font-size: var(--text-sm);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    white-space: nowrap;
    border: 1px solid transparent;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-600);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-700);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--border-light);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
}

.btn-success {
    background: var(--success-600);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-700);
}

.btn-danger {
    background: var(--error-600);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: var(--error-700);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--gray-100);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-medium);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--gray-50);
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

/* ============================================
   FORMULARIOS
   ============================================ */

.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.form-label-required::after {
    content: ' *';
    color: var(--error-500);
}

.form-control {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-control:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

.form-control.error {
    border-color: var(--error-500);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.form-hint {
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.form-error {
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    color: var(--error-600);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--primary-600);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
}