/* =====================================================
   SISTEMA DE INVENTARIO Y ALMACENES
   Estilos Base - iOS Inspired Design
   ===================================================== */

/* CSS Variables */
:root {
    --ios-blue: #007AFF;
    --ios-blue-dark: #0056b3;
    --ios-teal: #5AC8FA;
    --ios-green: #34C759;
    --ios-red: #FF3B30;
    --ios-orange: #FF9500;
    --ios-yellow: #FFCC00;
    --ios-purple: #AF52DE;
    --ios-pink: #FF2D55;
    --ios-gray: #8E8E93;
    --ios-gray-2: #AEAEB2;
    --ios-gray-3: #C7C7CC;
    --ios-gray-4: #D1D1D6;
    --ios-gray-5: #E5E5EA;
    --ios-gray-6: #F2F2F7;

    --ios-bg: #F2F2F7;
    --ios-card: #FFFFFF;
    --ios-text: #1C1C1E;
    --ios-text-secondary: #6C6C70;
    --ios-border: #E5E5EA;

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --header-height: 60px;
    --border-radius: 12px;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s ease;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ios-text);
    background-color: var(--ios-bg);
}

/* =====================================================
   LOGIN PAGE STYLES
   ===================================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #1B3A5C 0%, #0072BC 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: rgba(242, 169, 0, 0.15);
    border-radius: 50%;
    top: -200px;
    right: -200px;
    animation: float 6s ease-in-out infinite;
}

.login-container::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(242, 169, 0, 0.1);
    border-radius: 50%;
    bottom: -150px;
    left: -150px;
    animation: float 8s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 50px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo img {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--ios-text);
    margin-bottom: 5px;
}

.login-logo p {
    color: var(--ios-text-secondary);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--ios-text);
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--ios-gray-5);
    border-radius: 12px;
    font-size: 16px;
    transition: var(--transition);
    background: var(--ios-card);
}

.login-form input:focus {
    outline: none;
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.login-form .btn-login {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #0072BC 0%, #1B3A5C 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 10px;
}

.login-form .btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 114, 188, 0.3);
}

.login-error {
    background: rgba(255, 59, 48, 0.1);
    color: var(--ios-red);
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
}

.login-error.show {
    display: block;
}

/* =====================================================
   LAYOUT STYLES
   ===================================================== */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--ios-card);
    border-right: 1px solid var(--ios-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--ios-border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo img {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.sidebar-logo .sidebar-text {
    font-weight: 600;
    font-size: 15px;
    color: var(--ios-text);
}

/* Header Collapse Button (hamburger) */
.btn-collapse-header {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 16px;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-collapse-header:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Sidebar Collapsed State */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

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

.sidebar.collapsed .sidebar-header {
    padding: 15px 10px;
}

.sidebar.collapsed .sidebar-logo {
    justify-content: center;
}

.sidebar.collapsed .sidebar-logo img {
    width: 36px;
    height: 36px;
}

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

.sidebar.collapsed .sidebar-nav {
    padding: 15px 5px;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
    gap: 0;
}

.sidebar.collapsed .nav-item i {
    font-size: 18px;
}

.sidebar.collapsed .nav-subitem {
    padding-left: 12px !important;
}

.sidebar.collapsed .nav-submenu-items {
    max-height: 0 !important;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 15px 10px;
}

.nav-section {
    margin-bottom: 25px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ios-gray);
    padding: 0 15px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-radius: 10px;
    color: var(--ios-text);
    text-decoration: none;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--ios-gray-6);
}

.nav-item.active {
    background: rgba(0, 122, 255, 0.1);
    color: var(--ios-blue);
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.nav-item span {
    font-size: 14px;
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* Header */
.header {
    height: var(--header-height);
    background: linear-gradient(135deg, #1B3A5C 0%, #0072BC 100%);
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
    color: #FFFFFF;
}

.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ios-text-secondary);
    font-size: 13px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.user-details {
    line-height: 1.3;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    color: #FFFFFF;
}

.user-role {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

.btn-logout {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 25px;
}

/* =====================================================
   COMPONENTS
   ===================================================== */

/* Cards */
.card {
    background: var(--ios-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--ios-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 17px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--ios-border);
    background: var(--ios-gray-6);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--ios-card);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
}

.stat-icon.blue { background: linear-gradient(135deg, #007AFF, #5856D6); }
.stat-icon.green { background: linear-gradient(135deg, #2E8B57, #34C759); }
.stat-icon.orange { background: linear-gradient(135deg, #FF9500, #FF3B30); }
.stat-icon.purple { background: linear-gradient(135deg, #AF52DE, #5856D6); }
.stat-icon.teal { background: linear-gradient(135deg, #5AC8FA, #007AFF); }
.stat-icon.red { background: linear-gradient(135deg, #FF3B30, #FF2D55); }
.stat-icon.pink { background: linear-gradient(135deg, #FF2D55, #AF52DE); }
.stat-icon.indigo { background: linear-gradient(135deg, #5856D6, #3634A3); }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 5px;
}

.stat-info p {
    color: var(--ios-text-secondary);
    font-size: 13px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--ios-blue-dark);
}

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

.btn-danger {
    background: var(--ios-red);
    color: white;
}

.btn-warning {
    background: var(--ios-orange);
    color: white;
}

.btn-secondary {
    background: var(--ios-gray-5);
    color: var(--ios-text);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--ios-border);
    color: var(--ios-text);
}

/* Botones de toolbar (Buscar, Mostrar todos) */
.btn-buscar {
    background: var(--ios-teal);
    color: white;
    font-weight: 700;
}

.btn-buscar:hover {
    background: #4ab4e0;
}

.btn-mostrar-todos {
    background: var(--ios-orange);
    color: white;
    font-weight: 700;
}

.btn-mostrar-todos:hover {
    background: #e08600;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* Form Controls */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--ios-text);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--ios-border);
    border-radius: 10px;
    font-size: 14px;
    transition: var(--transition);
    background: var(--ios-card);
}

.form-control:focus {
    outline: none;
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238E8E93' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-inline {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--ios-border);
}

.table th {
    background: var(--ios-gray-6);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--ios-text-secondary);
}

.table tr:hover {
    background: var(--ios-gray-6);
}

.table tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: rgba(52, 199, 89, 0.15);
    color: var(--ios-green);
}

.badge-danger {
    background: rgba(255, 59, 48, 0.15);
    color: var(--ios-red);
}

.badge-warning {
    background: rgba(255, 149, 0, 0.15);
    color: var(--ios-orange);
}

.badge-info {
    background: rgba(90, 200, 250, 0.15);
    color: var(--ios-teal);
}

.badge-primary {
    background: rgba(0, 122, 255, 0.15);
    color: var(--ios-blue);
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: rgba(52, 199, 89, 0.15);
    color: #1a7f37;
    border: 1px solid rgba(52, 199, 89, 0.3);
}

.alert-danger {
    background: rgba(255, 59, 48, 0.15);
    color: #c41e3a;
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.alert-warning {
    background: rgba(255, 149, 0, 0.15);
    color: #b35c00;
    border: 1px solid rgba(255, 149, 0, 0.3);
}

.alert-info {
    background: rgba(0, 122, 255, 0.15);
    color: #0056b3;
    border: 1px solid rgba(0, 122, 255, 0.3);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--ios-card);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--ios-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--ios-gray-5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--ios-gray-4);
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--ios-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Search Box */
.search-box {
    position: relative;
    max-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--ios-border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--ios-gray-6);
}

.search-box input:focus {
    outline: none;
    border-color: var(--ios-blue);
    background: var(--ios-card);
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ios-gray);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--ios-text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--ios-text);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    color: var(--ios-text);
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--ios-gray-5);
}

.pagination .active {
    background: var(--ios-blue);
    color: white;
}

/* Stock Status */
.stock-bajo {
    color: var(--ios-red);
    font-weight: 600;
}

.stock-normal {
    color: var(--ios-green);
}

.stock-alto {
    color: var(--ios-orange);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

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

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

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

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Detail Row */
.detail-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.detail-row .detail-item {
    flex: 1;
}

.detail-label {
    font-size: 12px;
    color: var(--ios-text-secondary);
    margin-bottom: 4px;
}

.detail-value {
    font-weight: 500;
}

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

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

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

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

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

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .header-breadcrumb {
        display: none;
    }
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--ios-text-secondary); }
.text-success { color: var(--ios-green); }
.text-danger { color: var(--ios-red); }
.text-warning { color: var(--ios-orange); }
.text-primary { color: var(--ios-blue); }

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }
.p-1 { padding: 10px; }
.p-2 { padding: 20px; }
.p-3 { padding: 30px; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

/* Print Styles */
@media print {
    .sidebar,
    .header,
    .toolbar,
    .btn,
    .pagination {
        display: none !important;
    }

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

    .page-content {
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }
}
