/* Responsive Design cho các form theo kích thước màn hình */

/* Base styles cho tất cả thiết bị */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Desktop styles (màn hình lớn hơn 1024px) */
@media screen and (min-width: 1024px) {
    .form-row {
        display: flex;
        flex-wrap: wrap;
        margin: 0 -10px;
    }
    
    .form-col {
        flex: 1;
        padding: 0 10px;
        margin-bottom: 15px;
    }
    
    .form-col-half {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .form-col-third {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }
    
    .form-col-quarter {
        flex: 0 0 25%;
        max-width: 25%;
    }
    
    .card {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .table-responsive {
        overflow-x: auto;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .form-control {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* Tablet styles (768px - 1023px) */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    .form-row {
        display: flex;
        flex-wrap: wrap;
        margin: 0 -8px;
    }
    
    .form-col {
        flex: 1;
        padding: 0 8px;
        margin-bottom: 12px;
    }
    
    .form-col-half {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .form-col-third {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .form-col-quarter {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .card {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .table-responsive {
        overflow-x: auto;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .form-control {
        padding: 6px 10px;
        font-size: 13px;
    }
}

/* Mobile styles (nhỏ hơn 768px) */
@media screen and (max-width: 767px) {
    .form-row {
        display: block;
        margin: 0;
    }
    
    .form-col {
        width: 100%;
        padding: 0;
        margin-bottom: 10px;
    }
    
    .form-col-half,
    .form-col-third,
    .form-col-quarter {
        width: 100%;
        max-width: 100%;
    }
    
    .card {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .table-responsive {
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive table {
        min-width: 600px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 14px;
        width: 100%;
        margin-bottom: 5px;
    }
    
    .form-control {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    /* Ẩn một số cột không quan trọng trên mobile */
    .mobile-hide {
        display: none !important;
    }
    
    /* Stack buttons vertically */
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .btn-group .btn {
        margin: 0;
    }
}

/* Small mobile styles (nhỏ hơn 480px) */
@media screen and (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .card {
        padding: 8px;
        margin-bottom: 8px;
    }
    
    .btn {
        padding: 10px 12px;
        font-size: 16px; /* Tăng font size cho dễ touch */
    }
    
    .form-control {
        padding: 10px;
        font-size: 16px;
    }
    
    /* Giảm padding cho navbar */
    .navbar {
        padding: 5px 10px;
    }
    
    .navbar-brand {
        font-size: 16px;
    }
}

/* Utility classes cho responsive */
.responsive-text {
    font-size: clamp(12px, 2vw, 16px);
}

.responsive-heading {
    font-size: clamp(18px, 4vw, 24px);
}

.responsive-padding {
    padding: clamp(10px, 2vw, 20px);
}

/* Grid system linh hoạt */
.grid-auto-fit {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.grid-auto-fill {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

/* Flexbox utilities */
.flex-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.flex-responsive > * {
    flex: 1;
    min-width: 200px;
}

/* Responsive images */
.img-responsive {
    max-width: 100%;
    height: auto;
}

/* Responsive tables */
.table-responsive {
    border: 0;
}

.table-responsive table {
    width: 100%;
    border-collapse: collapse;
}

.table-responsive th,
.table-responsive td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

/* Responsive form elements */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Responsive buttons */
.btn {
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #1e7e34;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

/* Responsive alerts */
.alert {
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid transparent;
    border-radius: 4px;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

/* Responsive navigation */
.navbar {
    background-color: #343a40;
    color: white;
    padding: 10px 0;
}

.navbar-brand {
    font-size: 20px;
    font-weight: bold;
    text-decoration: none;
    color: white;
}

/* Responsive search panels */
.search-panel {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.search-panel input {
    width: 100%;
    margin-bottom: 10px;
}

/* Responsive dropdowns */
.dropdown-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    max-height: 200px;
    overflow-y: auto;
}

.dropdown-content.show {
    display: block;
}

.dropdown-item {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    cursor: pointer;
}

.dropdown-item:hover {
    background-color: #f1f1f1;
}

/* Responsive grid view */
.gridview-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.gridview-responsive table {
    min-width: 600px;
}

.gridview-responsive th,
.gridview-responsive td {
    white-space: nowrap;
    padding: 8px;
}

/* Responsive modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 5px;
}

@media screen and (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 15px;
    }
}

/* Responsive loading spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive device-specific adjustments */
.device-mobile .container {
    padding: 0 10px;
}

.device-tablet .container {
    padding: 0 20px;
}

.device-desktop .container {
    padding: 0 30px;
}

