/* ==========================================================================
   OORKANAKU Village Governance ERP - Responsive Design
   Breakpoints: XL, LG, MD, SM, XS
   ========================================================================== */

/* ========================================================================
   ULTRA WIDE (1920px+)
   ======================================================================== */

@media (min-width: 1920px) {
  :root {
    --ok-sidebar-width: 280px;
  }

  .ok-content {
    padding: var(--ok-space-8);
  }

  .ok-dashboard-stats {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--ok-space-6);
  }

  .ok-container {
    max-width: 1600px;
  }

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

/* ========================================================================
   DESKTOP (1200px - 1919px)
   ======================================================================== */

@media (max-width: 1919px) {
  .ok-dashboard-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ========================================================================
   LAPTOP (992px - 1199px)
   ======================================================================== */

@media (max-width: 1199px) {
  .ok-dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .ok-dashboard-main {
    grid-template-columns: 1fr;
  }

  .ok-dashboard-three {
    grid-template-columns: 1fr 1fr;
  }

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

  .ok-grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }

  .ok-grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }

  .ok-detail-grid {
    grid-template-columns: 1fr;
  }

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

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

  .ok-landing-footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--ok-space-6);
  }

  .ok-hero h1 {
    font-size: var(--ok-text-4xl);
  }

  .ok-login-right {
    width: 420px;
  }

  .ok-navbar-search {
    max-width: 320px;
  }
}

/* ========================================================================
   TABLET (768px - 991px)
   ======================================================================== */

@media (max-width: 991px) {
  /* Sidebar collapses to mini mode */
  .ok-sidebar {
    width: var(--ok-sidebar-mini-width);
  }

  .ok-main {
    margin-left: var(--ok-sidebar-mini-width);
  }

  .ok-sidebar-logo-text,
  .ok-sidebar-link-text,
  .ok-sidebar-link-arrow,
  .ok-sidebar-badge,
  .ok-sidebar-group-header,
  .ok-sidebar-user-info,
  .ok-sidebar-collapse-btn {
    display: none;
  }

  .ok-sidebar-logo {
    justify-content: center;
    padding: var(--ok-space-4) var(--ok-space-3);
  }

  .ok-sidebar-link {
    justify-content: center;
    padding: var(--ok-space-2-5) 0;
    margin: 1px var(--ok-space-1);
  }

  .ok-sidebar-user {
    justify-content: center;
    padding: var(--ok-space-2-5);
  }

  /* Show hamburger */
  .ok-navbar-hamburger {
    display: flex;
  }

  .ok-navbar-logo {
    display: none;
  }

  .ok-content {
    padding: var(--ok-space-4);
  }

  .ok-dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--ok-space-4);
  }

  .ok-grid-2 {
    grid-template-columns: 1fr;
  }

  .ok-grid-3 {
    grid-template-columns: 1fr;
  }

  .ok-grid-4 {
    grid-template-columns: 1fr;
  }

  .ok-dashboard-equal {
    grid-template-columns: 1fr;
  }

  .ok-dashboard-three {
    grid-template-columns: 1fr;
  }

  .ok-features-grid {
    grid-template-columns: 1fr;
    gap: var(--ok-space-4);
  }

  .ok-testimonials-grid {
    grid-template-columns: 1fr;
  }

  .ok-hero {
    padding: var(--ok-space-20) 0 var(--ok-space-16);
  }

  .ok-hero h1 {
    font-size: var(--ok-text-3xl);
  }

  .ok-hero p {
    font-size: var(--ok-text-md);
  }

  .ok-login-page {
    flex-direction: column;
  }

  .ok-login-left {
    padding: var(--ok-space-10) var(--ok-space-6) var(--ok-space-6);
  }

  .ok-login-right {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--ok-border-secondary);
    padding: var(--ok-space-6);
  }

  .ok-login-brand {
    margin-bottom: var(--ok-space-6);
  }

  .ok-login-gopuram {
    width: 80px;
    height: 80px;
    font-size: 2rem;
    margin-bottom: var(--ok-space-4);
  }

  .ok-landing-footer-grid {
    grid-template-columns: 1fr;
    gap: var(--ok-space-6);
  }

  .ok-footer {
    flex-direction: column;
    gap: var(--ok-space-2);
    text-align: center;
  }

  /* Sidebar submenu hover for collapsed mode */
  .ok-sidebar-item:hover > .ok-sidebar-submenu {
    position: fixed;
    left: var(--ok-sidebar-mini-width);
    top: 0;
    width: 220px;
    max-height: none !important;
    background: var(--ok-bg-sidebar);
    border-radius: 0 var(--ok-radius-lg) var(--ok-radius-lg) 0;
    box-shadow: var(--ok-shadow-xl);
    padding: var(--ok-space-2);
    z-index: calc(var(--z-sidebar) + 1);
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    overflow: visible;
  }

  .ok-sidebar-item:hover > .ok-sidebar-submenu .ok-sidebar-link {
    padding-left: var(--ok-space-3);
    margin: 1px 0;
    justify-content: flex-start;
  }

  .ok-content-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .ok-module-filters {
    width: 100%;
  }

  .ok-module-filters .ok-select,
  .ok-module-filters .ok-input {
    flex: 1;
    min-width: 0;
  }
}

/* ========================================================================
   MOBILE LANDSCAPE (576px - 767px)
   ======================================================================== */

@media (max-width: 767px) {
  /* Sidebar becomes off-canvas */
  .ok-sidebar {
    width: var(--ok-sidebar-width);
    transform: translateX(-100%);
    z-index: var(--z-sidebar);
  }

  .ok-wrapper:not(.sidebar-hidden) .ok-sidebar {
    transform: translateX(0);
  }

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

  /* Sidebar elements show again in mobile drawer */
  .ok-sidebar-logo-text,
  .ok-sidebar-link-text,
  .ok-sidebar-link-arrow,
  .ok-sidebar-badge,
  .ok-sidebar-group-header,
  .ok-sidebar-user-info,
  .ok-sidebar-collapse-btn {
    display: revert;
  }

  .ok-sidebar-logo {
    justify-content: flex-start;
    padding: var(--ok-space-4) var(--ok-space-5);
  }

  .ok-sidebar-link {
    justify-content: flex-start;
    padding: var(--ok-space-2-5) var(--ok-space-5);
    margin: 1px var(--ok-space-2);
  }

  .ok-sidebar-user {
    justify-content: flex-start;
    padding: var(--ok-space-2-5);
  }

  /* Overlay */
  .ok-sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--ok-bg-overlay);
    z-index: calc(var(--z-sidebar) - 1);
    opacity: 0;
    visibility: hidden;
    transition: all var(--ok-transition-base);
  }

  .ok-wrapper:not(.sidebar-hidden) .ok-sidebar-overlay {
    opacity: 1;
    visibility: visible;
  }

  .ok-content {
    padding: var(--ok-space-4);
  }

  .ok-dashboard-stats {
    grid-template-columns: 1fr;
  }

  .ok-stat-card {
    padding: var(--ok-space-4);
  }

  .ok-stat-card-icon {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
  }

  .ok-stat-card-value {
    font-size: var(--ok-text-xl);
  }

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

  .ok-grid-auto-fill {
    grid-template-columns: 1fr;
  }

  .ok-dashboard-equal,
  .ok-dashboard-three {
    grid-template-columns: 1fr;
  }

  .ok-hero h1 {
    font-size: var(--ok-text-2xl);
  }

  .ok-hero-actions {
    flex-direction: column;
  }

  .ok-hero-actions .ok-btn {
    width: 100%;
  }

  .ok-content-title {
    font-size: var(--ok-text-xl);
  }

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

  .ok-content-header .ok-btn {
    width: 100%;
  }

  .ok-modal {
    margin: var(--ok-space-4);
    max-height: calc(100vh - 32px);
  }

  .ok-modal-full {
    max-width: 100%;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .ok-notification-dropdown,
  .ok-messages-dropdown {
    position: fixed;
    top: var(--ok-navbar-height);
    left: 0;
    right: 0;
    width: 100%;
    max-height: calc(100vh - var(--ok-navbar-height));
    border-radius: 0;
  }

  .ok-user-menu-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: var(--ok-radius-2xl) var(--ok-radius-2xl) 0 0;
    max-height: 80vh;
  }

  .ok-breadcrumb-bar {
    padding: var(--ok-space-2) var(--ok-space-4);
    overflow-x: auto;
  }

  .ok-breadcrumb {
    white-space: nowrap;
  }

  .ok-navbar {
    padding: 0 var(--ok-space-3);
  }

  .ok-navbar-search {
    display: none;
  }

  .ok-table-responsive {
    border: 1px solid var(--ok-border-card);
    border-radius: var(--ok-radius-xl);
  }

  .ok-quick-actions {
    flex-wrap: wrap;
  }

  .ok-quick-action {
    flex: 1;
    min-width: calc(50% - var(--ok-space-2));
    justify-content: center;
  }

  .ok-report-header {
    flex-direction: column;
    gap: var(--ok-space-3);
  }

  .ok-report-actions {
    width: 100%;
  }

  .ok-report-actions .ok-btn {
    flex: 1;
  }

  .ok-info-row {
    flex-direction: column;
    gap: var(--ok-space-1);
  }

  .ok-info-label {
    width: auto;
  }

  .ok-pagination {
    flex-wrap: wrap;
    justify-content: center;
  }

  .ok-login-left {
    padding: var(--ok-space-6) var(--ok-space-4) var(--ok-space-4);
  }

  .ok-login-gopuram {
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
  }

  .ok-login-brand h1 {
    font-size: var(--ok-text-xl);
  }

  .ok-scroll-top {
    bottom: var(--ok-space-4);
    right: var(--ok-space-4);
    width: 40px;
    height: 40px;
  }

  .ok-accordion-header {
    padding: var(--ok-space-3) var(--ok-space-4);
  }

  .ok-accordion-content {
    padding: 0 var(--ok-space-4) var(--ok-space-4);
  }
}

/* ========================================================================
   MOBILE PORTRAIT (up to 575px)
   ======================================================================== */

@media (max-width: 575px) {
  .ok-content {
    padding: var(--ok-space-3);
  }

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

  .ok-stat-card {
    padding: var(--ok-space-3);
    gap: var(--ok-space-3);
  }

  .ok-stat-card-icon {
    width: 40px;
    height: 40px;
    font-size: 1.125rem;
  }

  .ok-stat-card-value {
    font-size: var(--ok-text-lg);
  }

  .ok-stat-card-label {
    font-size: var(--ok-text-xs);
  }

  .ok-card-body {
    padding: var(--ok-space-3);
  }

  .ok-card-header {
    padding: var(--ok-space-3) var(--ok-space-4);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--ok-space-2);
  }

  .ok-card-footer {
    padding: var(--ok-space-3) var(--ok-space-4);
    flex-wrap: wrap;
  }

  .ok-card-footer .ok-btn {
    flex: 1;
    min-width: 0;
  }

  .ok-hero {
    padding: var(--ok-space-16) 0 var(--ok-space-10);
  }

  .ok-hero h1 {
    font-size: var(--ok-text-xl);
  }

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

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

  .ok-hero-actions .ok-btn {
    height: 42px;
    font-size: var(--ok-text-sm);
  }

  .ok-content-title {
    font-size: var(--ok-text-lg);
  }

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

  .ok-tabs {
    gap: 0;
  }

  .ok-tab {
    padding: var(--ok-space-2) var(--ok-space-3);
    font-size: var(--ok-text-xs);
  }

  .ok-modal-header {
    padding: var(--ok-space-3) var(--ok-space-4);
  }

  .ok-modal-body {
    padding: var(--ok-space-4);
  }

  .ok-modal-footer {
    padding: var(--ok-space-3) var(--ok-space-4);
    flex-direction: column;
  }

  .ok-modal-footer .ok-btn {
    width: 100%;
  }

  .ok-login-form {
    max-width: 100%;
  }

  .ok-login-form h2 {
    font-size: var(--ok-text-xl);
  }

  .ok-login-remember {
    flex-direction: column;
    gap: var(--ok-space-3);
    align-items: flex-start;
  }

  .ok-empty-state {
    padding: var(--ok-space-8) var(--ok-space-4);
  }

  .ok-empty-state-icon {
    font-size: 2.5rem;
  }

  .ok-empty-state-title {
    font-size: var(--ok-text-md);
  }

  .ok-alert {
    padding: var(--ok-space-3);
  }

  .ok-timeline {
    padding-left: var(--ok-space-6);
  }

  .ok-timeline-dot {
    left: calc(-1 * var(--ok-space-6) + 8px);
    width: 14px;
    height: 14px;
  }

  .ok-section-title {
    font-size: var(--ok-text-md);
  }

  .ok-footer {
    padding: var(--ok-space-3);
    font-size: var(--ok-text-xs);
  }

  .ok-report-summary {
    grid-template-columns: 1fr 1fr;
    gap: var(--ok-space-3);
    padding: var(--ok-space-3);
  }

  .ok-report-summary-value {
    font-size: var(--ok-text-xl);
  }

  .ok-report-summary-label {
    font-size: var(--ok-text-xs);
  }

  .ok-widget-header {
    padding: var(--ok-space-3) var(--ok-space-4);
  }

  .ok-widget-body {
    padding: var(--ok-space-3);
  }

  .ok-module-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .ok-module-header .ok-btn {
    width: 100%;
  }

  .ok-module-filters .ok-select,
  .ok-module-filters .ok-input {
    width: 100%;
    min-width: 100%;
  }

  /* Table font size reduction */
  .ok-table {
    font-size: var(--ok-text-xs);
  }

  .ok-table thead th {
    padding: var(--ok-space-2) var(--ok-space-3);
    font-size: 0.625rem;
  }

  .ok-table tbody td {
    padding: var(--ok-space-2) var(--ok-space-3);
  }
}

/* ========================================================================
   PRINT RESPONSIVE OVERRIDES
   ======================================================================== */

@media print {
  @media (max-width: 767px) {
    .ok-table {
      font-size: 10pt;
    }

    .ok-stat-card {
      padding: 8pt;
    }

    .ok-content {
      padding: 0;
    }
  }
}
