/**
 * Main Styles - Sistema de Concesiones Comerciales
 */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--gray-800);
    background-color: var(--bg-body);
}

/* Viewport Warning */
.viewport-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-body);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: var(--space-8);
}

.viewport-warning-content {
    max-width: 400px;
}

.viewport-warning-icon {
    font-size: 48px;
    display: block;
    margin-bottom: var(--space-7);
}

.viewport-warning h2 {
    margin: 0 0 var(--space-5);
    font-size: var(--font-size-xl);
}

.viewport-warning p {
    margin: 0 0 var(--space-4);
    color: var(--gray-600);
}

/* Mobile Mode - Show app but with limited features */
@media (max-width: 1279px) {
    /* Hide viewport warning - we now support mobile */
    .viewport-warning {
        display: none !important;
    }
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--box-shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-8);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-5);
}

.header-logo {
    display: flex;
    align-items: center;
}

.header-logo img {
    height: 32px;
    width: auto;
}

.header-app-name {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--gray-800);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-5);
}

.header-notification {
    position: relative;
    font-size: 20px;
    text-decoration: none;
    padding: var(--space-2);
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: var(--font-weight-semibold);
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* User Menu */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-5);
    background: var(--gray-100);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.user-menu:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
}

.user-name {
    font-weight: var(--font-weight-medium);
    color: var(--gray-800);
}

.user-role {
    font-size: var(--font-size-sm);
    color: var(--gray-600);
}

.user-menu-arrow {
    font-size: 10px;
    color: var(--gray-500);
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + var(--space-3));
    right: 0;
    min-width: 200px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-xl);
    z-index: var(--z-dropdown);
}

.user-menu.open .user-menu-dropdown {
    display: block;
}

.user-menu-item {
    display: block;
    padding: var(--space-4) var(--space-7);
    color: var(--gray-700);
    text-decoration: none;
    transition: background var(--transition-fast);
}

.user-menu-item:hover {
    background: var(--gray-100);
}

.user-menu-danger {
    color: var(--danger);
}

.user-menu-divider {
    height: 1px;
    background: var(--border-color-light);
    margin: var(--space-2) 0;
}

/* Main Wrapper */
.main-wrapper {
    display: flex;
    flex: 1;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: var(--space-4) 0;
}

.sidebar-item {
    margin: 0;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-7);
    color: var(--gray-700);
    text-decoration: none;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-fast);
}

.sidebar-item a:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.sidebar-item.active a {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: var(--font-weight-semibold);
}

.sidebar-icon {
    font-size: 16px;
}

.sidebar-divider {
    height: 1px;
    background: var(--border-color-light);
    margin: var(--space-4) var(--space-7);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: var(--space-7);
    min-width: 0;
    max-width: calc(100% - var(--sidebar-width));
}

.main-content.full-width {
    max-width: 100%;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-7);
}

.page-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--gray-900);
    margin: 0;
}

.page-subtitle {
    font-size: var(--font-size-sm);
    color: var(--gray-600);
    margin-top: var(--space-1);
}

.page-actions {
    display: flex;
    gap: var(--space-3);
}

/* Breadcrumb */
.breadcrumb {
    font-size: var(--font-size-xs);
    color: var(--gray-600);
    margin-bottom: var(--space-4);
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    margin: 0 var(--space-2);
    color: var(--gray-400);
}

/* Alerts */
.alert {
    padding: var(--space-5) var(--space-7);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-7);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
}

.alert-success {
    background: var(--success-light);
    border: 1px solid var(--success);
    color: #0f5132;
}

.alert-danger {
    background: var(--danger-light);
    border: 1px solid var(--danger);
    color: #842029;
}

.alert-warning {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    color: #856404;
}

.alert-info {
    background: var(--info-light);
    border: 1px solid var(--info);
    color: #055160;
}

.alert-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.5;
}

.alert-close:hover {
    opacity: 1;
}

/* Utility Classes */
.text-muted {
    color: var(--gray-600) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-sm {
    font-size: var(--font-size-sm);
}

.text-xs {
    font-size: var(--font-size-xs);
}

.fw-medium {
    font-weight: var(--font-weight-medium);
}

.fw-semibold {
    font-weight: var(--font-weight-semibold);
}

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-3 { margin-top: var(--space-3); }
.mb-3 { margin-bottom: var(--space-3); }
.mt-5 { margin-top: var(--space-5); }
.mb-5 { margin-bottom: var(--space-5); }
.mt-7 { margin-top: var(--space-7); }
.mb-7 { margin-bottom: var(--space-7); }

.d-flex {
    display: flex;
}

.align-items-center {
    align-items: center;
}

.justify-content-between {
    justify-content: space-between;
}

.gap-3 {
    gap: var(--space-3);
}

.gap-5 {
    gap: var(--space-5);
}

/* Link styles */
a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--gray-600);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--space-5);
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--gray-800);
    margin: 0 0 var(--space-3);
}

.empty-state-text {
    margin: 0 0 var(--space-7);
}

/* Auth layout */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    padding: var(--space-8);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-lg);
    overflow: hidden;
}

.auth-header {
    background: var(--primary);
    color: white;
    padding: var(--space-8);
    text-align: center;
}

.auth-header img {
    height: 40px;
    margin-bottom: var(--space-5);
}

.auth-header h1 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    margin: 0;
}

.auth-body {
    padding: var(--space-8);
}

.auth-footer {
    padding: 0 var(--space-8) var(--space-8);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--gray-600);
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   Limited functionality: Requests & Approvals only
   ======================================== */

/* Solicitud page sidebar */
.solicitud-sidebar {
    width: 320px;
    flex-shrink: 0;
}

/* Mobile Notice Banner */
.mobile-notice {
    display: none;
    background: linear-gradient(90deg, var(--info), #0d8ecf);
    color: white;
    padding: 8px 16px;
    text-align: center;
    font-size: 12px;
}

.mobile-notice a {
    color: white;
    text-decoration: underline;
}

@media (max-width: 1279px) {
    .mobile-notice {
        display: block;
    }
}

/* Tablet & Mobile Breakpoints */
@media (max-width: 1279px) {
    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden;
    }

    /* Header adjustments */
    .header {
        padding: 0 var(--space-4);
    }

    .header-app-name {
        display: none;
    }

    .header-logo img {
        height: 28px;
    }

    /* Hide sidebar on mobile */
    .sidebar {
        display: none;
    }

    /* Full width main content */
    .main-wrapper {
        flex-direction: column;
        width: 100%;
    }

    .main-content {
        padding: var(--space-4);
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    /* Ensure all direct children expand full width */
    .main-content > * {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Page header stacking */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .page-actions {
        width: 100%;
        display: flex;
        gap: var(--space-2);
    }

    .page-actions .btn {
        flex: 1;
        justify-content: center;
    }

    /* Cards full width */
    .card {
        margin-bottom: var(--space-4);
        width: 100%;
        max-width: none;
    }

    /* All content full width */
    .kpi-grid,
    .filters-section,
    .table-container,
    .page-header,
    .page-actions,
    .btn {
        width: 100%;
        max-width: none;
    }

    /* Solicitud sidebar full width on mobile */
    .solicitud-sidebar {
        width: 100%;
    }

    /* Forms responsive */
    .d-flex.gap-5,
    .d-flex.gap-4,
    .d-flex.gap-3 {
        flex-direction: column !important;
        gap: 0 !important;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row > * {
        flex: none !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
    }

    /* Filter section */
    .filters-section {
        margin-bottom: var(--space-4);
    }

    .filters-row {
        flex-direction: column;
        gap: var(--space-3);
    }

    .filter-group {
        width: 100%;
    }

    /* Info rows in cards */
    .info-row {
        flex-direction: column;
        gap: 2px;
    }

    .info-label {
        min-width: 0;
    }

    /* Hide desktop-only elements */
    .desktop-only {
        display: none !important;
    }

    /* User menu simplified */
    .user-name {
        display: none;
    }

    .user-role {
        font-size: 11px;
    }
}

/* Phone specific (smaller screens) */
@media (max-width: 640px) {
    .header {
        padding: 0 var(--space-3);
    }

    .main-content {
        padding: var(--space-3);
    }

    .card-header,
    .card-body {
        padding: var(--space-4);
    }

    .page-title {
        font-size: var(--font-size-lg);
    }

    .page-subtitle {
        font-size: var(--font-size-sm);
    }

    /* Buttons smaller */
    .btn {
        padding: var(--space-3) var(--space-5);
        font-size: var(--font-size-sm);
    }

    /* Form controls */
    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Alerts */
    .alert {
        padding: var(--space-3);
        font-size: var(--font-size-sm);
    }

    /* Modal full screen on mobile */
    .modal-container {
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }

    .modal-overlay {
        padding: 0;
    }

    /* Approval actions stacked */
    .approval-actions {
        flex-direction: column;
    }

    .approval-actions .btn {
        width: 100%;
    }
}

/* Mobile bottom navigation for key actions */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: var(--space-2) var(--space-3);
    z-index: var(--z-fixed);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.mobile-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: var(--space-2);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-2) var(--space-3);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 10px;
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
}

.mobile-nav-icon {
    font-size: 20px;
}

.mobile-nav-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: white;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 10px;
    min-width: 14px;
    text-align: center;
}

@media (max-width: 1279px) {
    .mobile-nav {
        display: block;
    }

    /* Add padding to main content for bottom nav */
    .main-content {
        padding-bottom: 70px;
    }
}
