/* ========================================
   COMPREHENSIVE RESPONSIVE DESIGN SYSTEM
   ======================================== */

/* Import Design System */
@import url('design-system.css');
@import url('potolo-theme.css');

/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--potolo-font-family, 'Inter', 'Roboto', 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    background: var(--potolo-bg-main, #F0F8FF);
    color: var(--potolo-text-primary, #333333);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Grid Layout Fixes */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
    justify-items: center;
    justify-content: stretch;
}

.stat-card {
    width: 100%;
    max-width: 300px;
    box-sizing: border-box;
    margin: 0 auto;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    width: 100%;
}

.import-export-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
}

.supplier-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    width: 100%;
    justify-items: center;
    justify-content: stretch;
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Extra Large Desktop (1400px+) */
@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
        padding: 0 2rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .dashboard-grid {
        grid-template-columns: 2.5fr 1fr;
    }
}

/* Large Desktop (1200px - 1399px) */
@media (max-width: 1399px) and (min-width: 1200px) {
    .container {
        max-width: 1200px;
        padding: 0 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    
    .dashboard-grid {
        grid-template-columns: 2fr 1fr;
    }
}

/* Medium Desktop (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .container {
        max-width: 100%;
        padding: 0 1.5rem;
    }
    
    .navbar-content {
        padding: 0 1.5rem;
    }
    
    .nav-links {
        gap: 1.5rem;
    }
    
    .nav-links a {
        padding: 0.6rem 1.2rem;
        font-size: 0.95rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 1.2rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 2fr 1fr;
        gap: 1.5rem;
    }
    
    .filter-row {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Tablet Landscape (768px - 991px) */
@media (max-width: 991px) and (min-width: 768px) {
    .container {
        max-width: 100%;
        padding: 0 1rem;
        margin: 1rem auto;
    }
    
    .navbar-content {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }
    
    .nav-links a {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .user-info {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
        justify-items: center;
        justify-content: stretch;
    }
    
    .stat-card {
        max-width: 250px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .filter-row {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 1rem;
    }
    
    .import-export-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .supplier-actions-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 0.8rem;
        justify-items: center;
        justify-content: stretch;
    }
    
    .import-form, .export-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .import-form .btn, .export-controls .btn {
        width: 100%;
    }
    
    .data-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table table {
        min-width: 800px;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 90%;
        max-width: 600px;
    }
}

/* Tablet Portrait (576px - 767px) */
@media (max-width: 767px) and (min-width: 576px) {
    .container {
        padding: 0 0.8rem;
        margin: 0.8rem auto;
    }
    
    .navbar {
        padding: 0.8rem 1rem;
    }
    
    .navbar-content {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.8rem;
    }
    
    .nav-links a {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .nav-links a i {
        margin-right: 0.3rem;
    }
    
    .user-info {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
        font-size: 0.9rem;
    }
    
    .page-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1.5rem 1rem;
    }
    
    .page-header h1 {
        font-size: 1.8rem;
    }
    
    .page-header p {
        font-size: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
        justify-items: center;
        justify-content: stretch;
    }
    
    .stat-card {
        padding: 1.2rem;
        max-width: 200px;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    .stat-label {
        font-size: 0.85rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .main-content, .sidebar {
        padding: 1.5rem;
    }
    
    .section-title {
        font-size: 1.3rem;
        margin-bottom: 1.2rem;
    }
    
    .filter-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .form-group {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        padding: 0.8rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .actions-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .search-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .search-input {
        min-width: auto;
        width: 100%;
    }
    
    .filter-select {
        min-width: auto;
        width: 100%;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-buttons button {
        width: 100%;
        justify-content: center;
    }
    
    .data-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.85rem;
    }
    
    .data-table table {
        min-width: 700px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.6rem 0.4rem;
    }
    
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
        max-height: calc(100vh - 1rem);
        overflow-y: auto;
        padding: 1.5rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-row .form-group {
        width: 100%;
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .action-btn {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .metric-card {
        padding: 1.2rem;
    }
    
    .metric-value {
        font-size: 1.8rem;
    }
}

/* Mobile Large (480px - 575px) */
@media (max-width: 575px) and (min-width: 480px) {
    .container {
        padding: 0 0.5rem;
        margin: 0.5rem auto;
    }
    
    .navbar {
        padding: 0.6rem 0.8rem;
    }
    
    .navbar-content {
        padding: 0 0.8rem;
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .logo {
        font-size: 1.3rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.6rem;
    }
    
    .nav-links a {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .nav-links a i {
        margin-right: 0.2rem;
    }
    
    .user-info {
        flex-direction: column;
        gap: 0.3rem;
        text-align: center;
        font-size: 0.85rem;
    }
    
    .page-header {
        padding: 1rem 0.8rem;
        margin-bottom: 1rem;
    }
    
    .page-header h1 {
        font-size: 1.6rem;
    }
    
    .page-header p {
        font-size: 0.9rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.8rem;
        justify-items: center;
        justify-content: stretch;
    }
    
    .stat-card {
        padding: 1rem;
        max-width: 150px;
    }
    
    .stat-number {
        font-size: 1.6rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .main-content, .sidebar {
        padding: 1rem;
    }
    
    .section-title {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .data-table {
        font-size: 0.8rem;
    }
    
    .data-table table {
        min-width: 600px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem 0.3rem;
    }
    
    .modal-content {
        margin: 0.25rem;
        max-width: calc(100% - 0.5rem);
        max-height: calc(100vh - 0.5rem);
        padding: 1rem;
    }
    
    .modal-header h2 {
        font-size: 1.2rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .btn-sm {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .status-badge, .priority-badge {
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .action-buttons {
        gap: 0.3rem;
    }
    
    .action-buttons button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* Mobile Medium (360px - 479px) */
@media (max-width: 479px) and (min-width: 360px) {
    .container {
        padding: 0 0.25rem;
        margin: 0.25rem auto;
    }
    
    .navbar {
        padding: 0.5rem 0.5rem;
    }
    
    .navbar-content {
        padding: 0 0.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .logo {
        font-size: 1.2rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem;
    }
    
    .nav-links a {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .nav-links a i {
        display: none; /* Hide icons on very small screens */
    }
    
    .user-info {
        flex-direction: column;
        gap: 0.2rem;
        text-align: center;
        font-size: 0.8rem;
    }
    
    .page-header {
        padding: 0.8rem 0.5rem;
        margin-bottom: 0.8rem;
    }
    
    .page-header h1 {
        font-size: 1.4rem;
    }
    
    .page-header p {
        font-size: 0.85rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.6rem;
        justify-items: center;
        justify-content: stretch;
    }
    
    .stat-card {
        padding: 0.8rem;
        max-width: 100%;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .main-content, .sidebar {
        padding: 0.8rem;
    }
    
    .section-title {
        font-size: 1.1rem;
        margin-bottom: 0.8rem;
    }
    
    .data-table {
        font-size: 0.75rem;
    }
    
    .data-table table {
        min-width: 500px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.4rem 0.2rem;
    }
    
    .modal-content {
        margin: 0.1rem;
        max-width: calc(100% - 0.2rem);
        max-height: calc(100vh - 0.2rem);
        padding: 0.8rem;
    }
    
    .modal-header h2 {
        font-size: 1.1rem;
    }
    
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .status-badge, .priority-badge {
        padding: 0.15rem 0.4rem;
        font-size: 0.65rem;
    }
    
    .action-buttons {
        gap: 0.2rem;
    }
    
    .action-buttons button {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.6rem;
        font-size: 16px;
    }
}

/* Mobile Small (320px - 359px) */
@media (max-width: 359px) {
    .container {
        padding: 0 0.1rem;
        margin: 0.1rem auto;
    }
    
    .navbar {
        padding: 0.4rem 0.3rem;
    }
    
    .navbar-content {
        padding: 0 0.3rem;
        flex-direction: column;
        gap: 0.3rem;
    }
    
    .logo {
        font-size: 1.1rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.3rem;
    }
    
    .nav-links a {
        padding: 0.25rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .nav-links a i {
        display: none;
    }
    
    .user-info {
        flex-direction: column;
        gap: 0.15rem;
        text-align: center;
        font-size: 0.75rem;
    }
    
    .page-header {
        padding: 0.6rem 0.3rem;
        margin-bottom: 0.6rem;
    }
    
    .page-header h1 {
        font-size: 1.3rem;
    }
    
    .page-header p {
        font-size: 0.8rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        justify-items: center;
        justify-content: stretch;
    }
    
    .stat-card {
        padding: 0.6rem;
        max-width: 100%;
    }
    
    .stat-number {
        font-size: 1.4rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .main-content, .sidebar {
        padding: 0.6rem;
    }
    
    .section-title {
        font-size: 1rem;
        margin-bottom: 0.6rem;
    }
    
    .data-table {
        font-size: 0.7rem;
    }
    
    .data-table table {
        min-width: 450px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.3rem 0.15rem;
    }
    
    .modal-content {
        margin: 0.05rem;
        max-width: calc(100% - 0.1rem);
        max-height: calc(100vh - 0.1rem);
        padding: 0.6rem;
    }
    
    .modal-header h2 {
        font-size: 1rem;
    }
    
    .btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .btn-sm {
        padding: 0.15rem 0.3rem;
        font-size: 0.65rem;
    }
    
    .status-badge, .priority-badge {
        padding: 0.1rem 0.3rem;
        font-size: 0.6rem;
    }
    
    .action-buttons {
        gap: 0.15rem;
    }
    
    .action-buttons button {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.5rem;
        font-size: 16px;
    }
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

/* Hide elements on specific screen sizes */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Responsive text sizing */
@media (max-width: 480px) {
    .text-responsive {
        font-size: 0.9rem;
    }
    
    .text-responsive-lg {
        font-size: 1.1rem;
    }
    
    .text-responsive-sm {
        font-size: 0.8rem;
    }
}

/* Responsive spacing */
@media (max-width: 768px) {
    .spacing-responsive {
        margin: 0.5rem 0;
        padding: 0.5rem;
    }
}

/* Responsive grid adjustments */
@media (max-width: 992px) {
    .grid-responsive {
        grid-template-columns: 1fr !important;
    }
}

/* Touch-friendly elements */
@media (max-width: 768px) {
    .touch-friendly {
        min-height: 44px;
        min-width: 44px;
    }
    
    .touch-friendly input,
    .touch-friendly select,
    .touch-friendly button {
        min-height: 44px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .navbar,
    .actions-bar,
    .action-buttons,
    .modal,
    .btn {
        display: none !important;
    }
    
    .container {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    
    .data-table {
        border-collapse: collapse;
        width: 100%;
    }
    
    .data-table th,
    .data-table td {
        border: 1px solid #000;
        padding: 0.5rem;
    }
    
    .stat-card {
        border: 1px solid #000;
        break-inside: avoid;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus styles for better accessibility */
.btn:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .stat-card {
        border: 2px solid #000;
    }
    
    .data-table th {
        background: #000;
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support - Enhanced for WCAG 2.1 AA contrast compliance */
@media (prefers-color-scheme: dark) {
    body {
        background: #1a1a1a;
        color: #ffffff; /* High contrast white on dark background (21:1 ratio) */
    }
    
    /* Text colors - ensure minimum 4.5:1 contrast ratio */
    .text-primary,
    h1, h2, h3, h4, h5, h6 {
        color: #ffffff; /* 21:1 contrast on #1a1a1a */
    }
    
    .text-secondary {
        color: #e0e0e0; /* 12.6:1 contrast on #1a1a1a */
    }
    
    .text-muted {
        color: #b0b0b0; /* 7.1:1 contrast on #1a1a1a - meets AA standard */
    }
    
    /* Cards and containers */
    .stat-card {
        background: #2d2d2d;
        color: #ffffff; /* 15.3:1 contrast on #2d2d2d */
        border: 1px solid #444444;
    }
    
    .card,
    .chart-section {
        background: #2d2d2d;
        color: #ffffff;
        border: 1px solid #444444;
    }
    
    /* Tables */
    .data-table th {
        background: #333333;
        color: #ffffff; /* 13.8:1 contrast on #333333 */
    }
    
    .data-table td {
        color: #ffffff; /* 13.8:1 contrast on #2d2d2d */
    }
    
    .data-table tr:hover {
        background: #444444;
        color: #ffffff;
    }
    
    /* Buttons - ensure text is readable */
    .btn {
        color: #ffffff;
    }
    
    .btn-primary {
        background: #667eea;
        color: #ffffff; /* 4.6:1 contrast on #667eea */
        border-color: #667eea;
    }
    
    .btn-secondary {
        background: #6b7280;
        color: #ffffff; /* 4.5:1 contrast on #6b7280 */
        border-color: #6b7280;
    }
    
    /* Status badges */
    .status-badge {
        color: #ffffff;
        font-weight: 600;
    }
    
    .status-badge.status-completed,
    .status-badge.status-approved {
        background: #10b981;
        color: #ffffff; /* 4.8:1 contrast on #10b981 */
    }
    
    .status-badge.status-pending,
    .status-badge.status-in-progress {
        background: #f59e0b;
        color: #000000; /* 8.6:1 contrast on #f59e0b */
    }
    
    .status-badge.status-rejected,
    .status-badge.status-error {
        background: #ef4444;
        color: #ffffff; /* 5.1:1 contrast on #ef4444 */
    }
    
    /* Chart colors - ensure labels are readable */
    .chart-container {
        color: #ffffff;
    }
    
    .chart-title {
        color: #ffffff;
    }
    
    /* Form inputs */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        background: #2d2d2d;
        color: #ffffff; /* 15.3:1 contrast on #2d2d2d */
        border: 1px solid #444444;
    }
    
    input[type="text"]:focus,
    input[type="email"]:focus,
    input[type="number"]:focus,
    input[type="date"]:focus,
    select:focus,
    textarea:focus {
        border-color: #667eea;
        outline: 2px solid #667eea;
        outline-offset: 2px;
    }
    
    /* Links */
    a {
        color: #60a5fa; /* 4.7:1 contrast on #1a1a1a */
    }
    
    a:hover {
        color: #93c5fd; /* Lighter blue for hover */
    }
    
    /* KPI items */
    .kpi-item-value {
        color: #ffffff;
    }
    
    .kpi-item-label {
        color: #e0e0e0;
    }
}






