/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

body.main-page,
body.settings-page {
    display: flex;
}

body.sidebar-open {
    overflow: hidden;
}

body.login-page {
    display: block;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 70px;
    max-height: 70px;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 0;
    min-width: 260px;
    max-width: 260px;
    width: 260px;
    
    /* Ẩn scrollbar nhưng vẫn scroll được */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
    min-height: 45px;
    width: 100%;
}

.menu-item .badge-notify {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.menu-item:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding-left: 25px;
}

.menu-item.active {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-left: 4px solid #fff;
}

.menu-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.menu-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.menu-item span {
    flex: 1;
}

.menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 15px 20px;
}

.menu-section {
    padding: 15px 20px 5px;
}

.menu-section-title {
    font-size: 11px;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.badge-soon {
    background: #3b82f6;
    color: white;
}

.badge-new {
    background: #10b981;
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info i {
    font-size: 40px;
    color: #667eea;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: #94a3b8;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 999;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    transform: scale(1.1);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-width: 0;
    width: calc(100% - 260px);
    padding: 20px;
    transition: margin-left 0.3s ease;
    overflow-x: auto;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header h1 {
    font-size: 28px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header h1 i {
    font-size: 32px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-add {
    background: #10b981;
    color: white;
}

.btn-add:hover {
    background: #059669;
}

.btn-back {
    background: #6b7280;
    color: white;
}

.btn-back:hover {
    background: #4b5563;
}

.btn-edit {
    background: #3b82f6;
    color: white;
    padding: 8px 12px;
    font-size: 13px;
}

.btn-edit:hover {
    background: #2563eb;
}

.btn-delete {
    background: #ef4444;
    color: white;
    padding: 8px 12px;
    font-size: 13px;
}

.btn-delete:hover {
    background: #dc2626;
}

.btn-submit {
    background: #10b981;
    color: white;
    font-size: 16px;
}

.btn-submit:hover {
    background: #059669;
}

.btn-cancel {
    background: #6b7280;
    color: white;
    font-size: 16px;
}

.btn-cancel:hover {
    background: #4b5563;
}

.btn-toggle-pass {
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0 5px;
    font-size: 14px;
}

.btn-toggle-pass:hover {
    color: #3b82f6;
}

/* Alerts */
.alert {
    margin: 20px 30px;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
    transition: opacity 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

/* Zalo notification box */
.zalo-info {
    background: linear-gradient(135deg, #0068ff 0%, #0180ff 100%);
    color: white;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0, 104, 255, 0.3);
}

.zalo-info i {
    font-size: 20px;
}

/* Table */
.table-container {
    padding: 20px 30px;
    overflow-x: auto;
    position: relative;
}

.table-scroll-hint {
    display: none;
    text-align: center;
    padding: 10px;
    background: #fef3c7;
    color: #92400e;
    font-size: 13px;
    border-radius: 6px;
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    .table-scroll-hint {
        display: block;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

thead th {
    padding: 15px 10px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

tbody tr:hover {
    background: #f9fafb;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Trạng thái VPS - Hết hạn (Đỏ) */
tbody tr.row-expired {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
}

tbody tr.row-expired:hover {
    background: #fecaca;
}

/* Trạng thái VPS - Cảnh báo còn 3 ngày (Vàng) */
tbody tr.row-warning {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
}

tbody tr.row-warning:hover {
    background: #fde68a;
}

/* Trạng thái VPS - Hoạt động bình thường */
tbody tr:not(.row-expired):not(.row-warning) {
    background: #f0fdf4;
    border-left: 4px solid #10b981;
}

tbody tr:not(.row-expired):not(.row-warning):hover {
    background: #dcfce7;
}

tbody tr.expired {
    background: #fee2e2;
}

tbody td {
    padding: 12px 10px;
}

.password-field {
    display: flex;
    align-items: center;
    gap: 5px;
}

.price {
    color: #10b981;
    font-weight: 600;
}

/* Status badges */
.status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-warning {
    background: #fef3c7;
    color: #92400e;
}

.status-expired {
    background: #fee2e2;
    color: #991b1b;
}

/* Action buttons in table */
.action-buttons {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

/* No data */
.no-data {
    text-align: center;
    padding: 40px !important;
    color: #9ca3af;
    font-size: 16px;
}

.no-data i {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

/* Footer */
.footer {
    background: #f9fafb;
    padding: 15px 30px;
    text-align: center;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
}

.footer strong {
    color: #3b82f6;
}

/* Form Styles */
.form-container {
    padding: 30px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group label i {
    color: #667eea;
}

.required {
    color: #ef4444;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group small {
    display: block;
    font-size: 12px;
    font-style: italic;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    justify-content: center;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .sidebar-overlay {
        display: block;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        margin-left: 0;
        padding: 70px 10px 10px;
    }

    .header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .header h1 {
        font-size: 22px;
    }

    /* Table responsive */
    .table-container {
        padding: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 11px;
        min-width: 1000px; /* Đảm bảo table có đủ không gian */
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    thead, tbody, tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }

    thead th,
    tbody td {
        padding: 8px 4px;
        font-size: 11px;
    }

    /* Ẩn một số cột không quan trọng trên mobile */
    .hide-mobile {
        display: none;
    }

    .action-buttons {
        flex-direction: row;
        gap: 5px;
    }

    .action-buttons .btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .status {
        font-size: 10px;
        padding: 4px 8px;
    }

    .price {
        font-size: 11px;
    }

    /* Form responsive */
    .form-container {
        padding: 15px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .form-group label {
        font-size: 13px;
    }

    .form-group input,
    .form-group select {
        font-size: 14px;
        padding: 10px 12px;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    /* Footer */
    .footer {
        padding: 12px 15px;
        font-size: 12px;
    }

    /* Alert */
    .alert {
        margin: 15px 10px;
        padding: 12px 15px;
        font-size: 13px;
    }

    /* Password field */
    .password-field {
        font-size: 11px;
    }

    .btn-toggle-pass {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 280px;
    }

    .main-content {
        padding: 60px 5px 5px;
    }

    .header h1 {
        font-size: 18px;
    }

    .header h1 i {
        font-size: 20px;
    }
    
    table {
        font-size: 10px;
        min-width: 900px;
    }
    
    thead th,
    tbody td {
        padding: 6px 3px;
        font-size: 10px;
    }

    .status {
        font-size: 9px;
        padding: 3px 6px;
    }

    .btn {
        font-size: 13px;
        padding: 8px 15px;
    }

    .action-buttons .btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    .form-container {
        padding: 10px;
    }

    .form-group input,
    .form-group select {
        font-size: 13px;
        padding: 9px 10px;
    }

    .container {
        border-radius: 10px;
    }

    /* Scrollbar cho bảng */
    .table-container::-webkit-scrollbar {
        height: 8px;
    }

    .table-container::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }

    .table-container::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 4px;
    }

    .table-container::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }

    .header,
    .btn,
    .action-buttons,
    .alert {
        display: none !important;
    }

    .container {
        box-shadow: none;
    }
}
