/* =========================================
   CUSTOM RESPONSIVE STYLES - AgroERP
   ========================================= */

/* Global Styles */
* {
    box-sizing: border-box;
}

body {
    font-size: 14px;
}

/* Sticky Footer - Override theme's absolute positioning */
body {
    min-height: 100vh;
}

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.dashboard-section {
    flex: 1;
}

@media (max-width: 768px) {
    body {
        font-size: 13px;
    }
}

/* =========================================
   LOGIN PAGE - Responsive
   ========================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-page .form-outer {
    width: 100%;
    max-width: 420px;
    padding: 30px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.1);
}

.login-page .logo {
    font-size: 28px;
    margin-bottom: 10px;
}

.login-page .form-inner p {
    color: #777;
    margin-bottom: 25px;
}

.login-page .form-group-material {
    position: relative;
    margin-bottom: 25px;
}

.login-page .input-material {
    width: 100%;
    padding: 12px 0;
    font-size: 15px;
    border: none;
    border-bottom: 1px solid #ddd;
    outline: none;
    background: transparent;
    transition: border-color 0.3s;
}

.login-page .input-material:focus {
    border-bottom-color: #384b64;
}

.login-page .label-material {
    position: absolute;
    top: 12px;
    left: 0;
    font-size: 15px;
    color: #999;
    transition: all 0.3s;
    pointer-events: none;
}

.login-page .input-material:focus ~ .label-material,
.login-page .input-material:not(:placeholder-shown) ~ .label-material {
    top: -10px;
    font-size: 12px;
    color: #384b64;
}

.login-page .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    margin-top: 10px;
}

.login-page .copyrights {
    margin-top: 25px;
    font-size: 12px;
    color: #888;
}

/* =========================================
   SIDEBAR - Mobile Responsive
   ========================================= */
@media (max-width: 1199px) {
    .side-navbar {
        margin-left: -70px;
    }

    .page {
        margin-left: 0;
    }

    .side-navbar.active {
        margin-left: 0;
    }
}

@media (max-width: 767px) {
    .side-navbar {
        margin-left: -70px;
        position: fixed;
        z-index: 1000;
        height: 100vh;
        overflow-y: auto;
    }

    .side-navbar.active {
        margin-left: 0;
    }

    .navbar-header {
        width: 100%;
    }
}

/* =========================================
   NAVBAR - Responsive
   ========================================= */
.navbar {
    padding: 10px 15px;
}

.navbar-brand {
    font-size: 18px;
}

@media (max-width: 576px) {
    .navbar-brand .brand-text {
        display: none !important;
    }
}

/* =========================================
   BREADCRUMB - Responsive
   ========================================= */
.breadcrumb-holder {
    padding: 15px 0;
}

.breadcrumb {
    margin-bottom: 0;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.breadcrumb h4 {
    font-size: 18px;
    margin: 0;
}

@media (max-width: 576px) {
    .breadcrumb h4 {
        font-size: 16px;
    }
}

/* =========================================
   CARDS - Responsive
   ========================================= */
.card {
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.card-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 15px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

@media (max-width: 767px) {
    .card-body {
        padding: 15px;
    }
}

/* Dashboard cards */
.data-usage {
    text-align: center;
    padding: 20px;
    height: 100%;
}

.data-usage h2 {
    font-size: 16px;
    margin-bottom: 15px;
}

.data-usage p {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

@media (max-width: 1199px) {
    .data-usage h2 {
        font-size: 15px;
    }

    .data-usage p {
        font-size: 12px;
    }
}

@media (max-width: 767px) {
    .data-usage {
        margin-bottom: 20px;
    }

    .data-usage h2 {
        font-size: 14px;
    }
}

/* =========================================
   FORMS - Responsive
   ========================================= */
.form-group {
    margin-bottom: 1rem;
}

.form-control {
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 4px;
}

.form-control:focus {
    border-color: #384b64;
    box-shadow: 0 0 0 0.2rem rgba(56, 75, 100, 0.25);
}

label {
    font-weight: 500;
    margin-bottom: 5px;
    font-size: 13px;
}

@media (max-width: 767px) {
    .form-control {
        font-size: 13px;
        padding: 8px 10px;
    }

    label {
        font-size: 12px;
    }
}

/* Input groups */
.input-group {
    width: 100%;
}

.input-group-text {
    background: #f8f9fa;
    border: 1px solid #ddd;
}

/* =========================================
   BUTTONS - Responsive
   ========================================= */
.btn {
    padding: 8px 18px;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.15s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1.4;
    vertical-align: middle;
}

.btn i {
    font-size: 1em;
    line-height: 1;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 5px;
    gap: 5px;
}

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

.btn-block {
    width: 100%;
}

/* Icon-only buttons in table action cells */
td .btn-sm {
    min-width: 32px;
    min-height: 32px;
    padding: 0 8px;
}

@media (max-width: 767px) {
    .btn {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 42px;
        border-radius: 8px;
    }

    .btn-sm {
        padding: 7px 12px;
        font-size: 13px;
        min-height: 36px;
        border-radius: 6px;
    }

    /* Icon-only buttons in tables on mobile */
    td .btn-sm {
        min-width: 36px;
        min-height: 36px;
        padding: 0 8px;
        font-size: 14px;
    }

    /* Card footer / form action buttons */
    .card-footer .btn {
        min-height: 44px;
        font-size: 15px;
    }

    /* Export / toolbar small buttons keep compact */
    .card-header .btn-sm {
        min-height: 34px;
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* =========================================
   TABLES - Responsive
   ========================================= */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Table scrollable - for tables with many rows */
.table-scrollable {
    max-height: 70vh;
    overflow-y: auto;
}

/* Smaller height for report tables inside card-body */
.card-body .table-scrollable,
.table-scrollable-sm {
    max-height: 50vh;
}

/* Ensure tables don't cause layout issues */
.card {
    margin-bottom: 20px;
    page-break-inside: avoid;
}

.card-body .table-scrollable + .card-header,
.table-scrollable + .card {
    margin-top: 20px;
}

.table {
    font-size: 13px;
    margin-bottom: 0;
}

.table thead th {
    font-weight: 600;
    font-size: 12px;
    padding: 12px 8px;
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 8px;
    vertical-align: middle;
}

.table-sm thead th {
    font-size: 11px;
    padding: 8px 5px;
}

.table-sm tbody td {
    padding: 8px 5px;
}

/* Make tables horizontally scrollable on mobile */
@media (max-width: 767px) {
    .table {
        font-size: 12px;
    }

    .table thead th,
    .table tbody td {
        padding: 8px 5px;
    }

    .table-sm thead th {
        font-size: 10px;
    }

    /* Ensure django_tables2 tables are responsive */
    .table-wrapper {
        overflow-x: auto;
    }
}

/* =========================================
   GRID SYSTEM - Responsive Utilities
   ========================================= */
@media (max-width: 576px) {
    /* Stack columns on mobile */
    .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5,
    .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10,
    .col-lg-11, .col-lg-12,
    .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5,
    .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10,
    .col-md-11, .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Add spacing between stacked columns */
    .row > [class*="col-"] {
        margin-bottom: 15px;
    }

    .row > [class*="col-"]:last-child {
        margin-bottom: 0;
    }
}

/* =========================================
   ALERTS - Responsive
   ========================================= */
.alert {
    padding: 12px 15px;
    font-size: 13px;
    border-radius: 4px;
}

.alert-dismissible .close {
    padding: 10px 15px;
}

@media (max-width: 576px) {
    .alert {
        font-size: 12px;
        padding: 10px 12px;
    }
}

/* =========================================
   MODALS - Responsive
   ========================================= */
.modal-content {
    border-radius: 8px;
    border: none;
}

.modal-header {
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px;
    border-top: 1px solid #e9ecef;
}

@media (max-width: 576px) {
    .modal-dialog {
        margin: 10px;
    }

    .modal-content {
        padding: 0;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 12px;
    }
}

/* =========================================
   FOOTER - Responsive and Sticky Fix
   ========================================= */

/* Override theme's absolute positioning - this fixes footer appearing in middle of page */
footer.main-footer,
.main-footer {
  position: relative !important;
  margin-top: auto !important;
}

/* Ensure the page wrapper uses flexbox for sticky footer */
.page {
  display: flex !important;
  flex-direction: column !important;
  min-height: 100vh !important;
}

/* Ensure the dashboard section can grow */
.dashboard-section {
  flex: 1 !important;
}

.main-footer {
  background: #f8f9fa;
  padding: 20px 0;
  margin-top: 40px;
}

.main-footer p {
  margin: 0;
  font-size: 13px;
  color: #666;
}

@media (max-width: 576px) {
  .main-footer {
    text-align: center;
  }

  .main-footer .row > div {
    margin-bottom: 10px;
  }
}

/* =========================================
   SEARCH BAR - Responsive
   ========================================= */
#buscador {
    font-size: 14px;
}

@media (max-width: 767px) {
    #form-busqueda {
        width: 100%;
    }

    #buscador {
        font-size: 13px;
    }
}

/* =========================================
   ACTION BUTTONS - Responsive
   ========================================= */
.btn-group-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

@media (max-width: 576px) {
    .btn-group-responsive .btn {
        flex: 1 1 auto;
        text-align: center;
    }
}

/* Table row action buttons — consistent spacing */
td .d-flex .btn + .btn,
td .btn-group .btn + .btn {
    margin-left: 4px;
}

/* Action bar (add button + search) on mobile */
@media (max-width: 767px) {
    .card-body .row.align-items-center > [class*="col-"] .btn {
        width: 100%;
    }
}

/* =========================================
   PRINT STYLES
   ========================================= */
@media print {
    .side-navbar,
    .navbar,
    .breadcrumb-holder,
    .main-footer,
    .btn,
    .no-print {
        display: none !important;
    }

    .page {
        margin-left: 0 !important;
    }

    .table {
        font-size: 10px;
    }
}

/* =========================================
   UTILITY CLASSES
   ========================================= */
.text-small {
    font-size: 12px;
}

.text-muted-light {
    color: rgba(255, 255, 255, 0.7);
}

.shadow-sm {
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
}

.rounded-lg {
    border-radius: 8px !important;
}

/* Spacing utilities for mobile */
@media (max-width: 576px) {
    .mb-md-0 {
        margin-bottom: 0 !important;
    }

    .mb-md-2 {
        margin-bottom: 0.5rem !important;
    }

    .mb-md-3 {
        margin-bottom: 1rem !important;
    }

    .text-md-center {
        text-align: center !important;
    }

    .d-md-block {
        display: block !important;
    }
}

/* =========================================
   SCROLLBAR - Custom Styling
   ========================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* =========================================
   LOADING STATES
   ========================================= */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* =========================================
   DATE PICKER - Mobile Fixes
   ========================================= */
.bootstrap-datetimepicker-widget {
    font-size: 14px;
}

@media (max-width: 576px) {
    .bootstrap-datetimepicker-widget {
        font-size: 12px;
    }

    .bootstrap-datetimepicker-widget .btn {
        padding: 5px 8px;
    }
}

/* =========================================
   CRISPY FORMS - Responsive
   ========================================= */
.crispy-form .form-group {
    margin-bottom: 1rem;
}

@media (max-width: 767px) {
    .crispy-form .row {
        margin: 0;
    }

    .crispy-form .col-form-label {
        padding: 0;
        margin-bottom: 5px;
    }
}

/* Botones Personalizados PDF y Eliminar */
.btn-pdf { color: #fff; background-color: #e74c3c; border-color: #e74c3c; }
.btn-pdf:hover { color: #fff; background-color: #c0392b; border-color: #b53224; }
.btn-eliminar { color: #fff; background-color: #bd2130; border-color: #b21f2d; }
.btn-eliminar:hover { color: #fff; background-color: #8b1014; border-color: #7c0e12; }

/* mr-1 / mr-2 dentro de botones ya no es necesario con gap, pero mantener compatibilidad */
.btn > .mr-1 { margin-right: 0 !important; }
.btn > .mr-2 { margin-right: 0 !important; }

