/* Responsive Components for KICT CRM */

/* ===== RESPONSIVE FORMS ===== */
.form-container {
    max-width: 100%;
    margin: 0 auto;
}

.form-row {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

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

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

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

@media (max-width: 992px) {
    .form-row-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .form-row-2,
    .form-row-3,
    .form-row-4 {
        grid-template-columns: 1fr;
    }
    
    .form-container {
        padding: 0 1rem;
    }
}

/* ===== RESPONSIVE TABLES ===== */
.table-container {
    background: var(--card-bg);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--card-border);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

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

.table-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .table-actions {
        justify-content: stretch;
    }
    
    .table-actions .btn {
        flex: 1;
        min-width: 0;
    }
}

/* ===== RESPONSIVE MODALS ===== */
.modal-responsive {
    max-width: 90vw;
    margin: 1rem auto;
}

.modal-body-responsive {
    max-height: 70vh;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .modal-responsive {
        max-width: 95vw;
        margin: 0.5rem;
    }
    
    .modal-body-responsive {
        max-height: 60vh;
    }
}

/* ===== RESPONSIVE CARDS ===== */
.card-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

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

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

@media (max-width: 1200px) {
    .card-grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .card-grid-3,
    .card-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .card-grid-2,
    .card-grid-3,
    .card-grid-4 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* ===== RESPONSIVE STATISTICS ===== */
.stats-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

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

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

@media (max-width: 992px) {
    .stats-grid-3,
    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .stats-grid-2,
    .stats-grid-3,
    .stats-grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ===== RESPONSIVE SEARCH AND FILTERS ===== */
.search-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: end;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-item {
    min-width: 120px;
}

@media (max-width: 768px) {
    .search-filters {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .filter-group {
        justify-content: stretch;
    }
    
    .filter-item {
        flex: 1;
        min-width: 0;
    }
}

/* ===== RESPONSIVE BUTTON GROUPS ===== */
.btn-group-responsive {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-group-responsive .btn {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
}

@media (max-width: 576px) {
    .btn-group-responsive {
        flex-direction: column;
    }
    
    .btn-group-responsive .btn {
        width: 100%;
    }
}

/* ===== RESPONSIVE NAVIGATION ===== */
.nav-tabs-responsive {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.nav-tabs-responsive .nav-link {
    white-space: nowrap;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.nav-tabs-responsive .nav-link.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.nav-tabs-responsive .nav-link:hover {
    color: var(--text-primary);
}

/* ===== RESPONSIVE PAGINATION ===== */
.pagination-responsive {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.pagination-info {
    margin: 0 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

@media (max-width: 576px) {
    .pagination-responsive {
        flex-direction: column;
        gap: 1rem;
    }
    
    .pagination-info {
        margin: 0;
        order: -1;
    }
}

/* ===== RESPONSIVE IMAGES ===== */
.img-responsive {
    max-width: 100%;
    height: auto;
    display: block;
}

.img-fluid {
    width: 100%;
    height: auto;
}

/* ===== RESPONSIVE EMBEDDED CONTENT ===== */
.embed-responsive {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.embed-responsive iframe,
.embed-responsive object,
.embed-responsive embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ===== RESPONSIVE TEXT ===== */
.text-responsive {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.text-truncate-responsive {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .text-truncate-responsive {
        white-space: normal;
        word-wrap: break-word;
    }
}

/* ===== RESPONSIVE SPACING ===== */
.spacing-responsive {
    margin: 1rem 0;
}

@media (max-width: 768px) {
    .spacing-responsive {
        margin: 0.75rem 0;
    }
}

@media (max-width: 576px) {
    .spacing-responsive {
        margin: 0.5rem 0;
    }
}

/* ===== RESPONSIVE UTILITIES ===== */
.hide-on-mobile {
    display: block;
}

.show-on-mobile {
    display: none;
}

@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }
    
    .show-on-mobile {
        display: block !important;
    }
}

/* ===== RESPONSIVE PRINT STYLES ===== */
@media print {
    .hide-on-print {
        display: none !important;
    }
    
    .show-on-print {
        display: block !important;
    }
    
    .card-grid,
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .table-responsive {
        overflow: visible !important;
    }
    
    .modal {
        position: static !important;
        transform: none !important;
    }
}

/* ===== RESPONSIVE ANIMATIONS ===== */
@media (prefers-reduced-motion: reduce) {
    .fade-in,
    .slide-in,
    .bounce-in {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ===== RESPONSIVE FOCUS STATES ===== */
.focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .focus-visible {
        outline-width: 3px;
        outline-offset: 1px;
    }
}

/* ===== RESPONSIVE LOADING STATES ===== */
.loading-responsive {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    width: 100%;
}

.loading-spinner-responsive {
    width: 40px;
    height: 40px;
    border: 4px solid var(--card-border);
    border-top: 4px solid var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@media (max-width: 768px) {
    .loading-responsive {
        min-height: 150px;
    }
    
    .loading-spinner-responsive {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== RESPONSIVE ERROR STATES ===== */
.error-responsive {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    margin: 1rem 0;
    color: var(--accent-red);
}

.error-responsive .error-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.error-responsive .error-message {
    font-size: 0.875rem;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .error-responsive {
        padding: 0.75rem;
        margin: 0.75rem 0;
    }
}

/* ===== RESPONSIVE SUCCESS STATES ===== */
.success-responsive {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    margin: 1rem 0;
    color: var(--accent-green);
}

.success-responsive .success-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.success-responsive .success-message {
    font-size: 0.875rem;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .success-responsive {
        padding: 0.75rem;
        margin: 0.75rem 0;
    }
}
