/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    transition: background-color 0.3s, color 0.3s;
}

body.dark {
    color: #e5e7eb;
}

.container {
    max-width: 1200px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1rem;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    color: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-title {
    font-size: 1.75rem;
    font-weight: 600;
}

.user-info {
    font-size: 0.875rem;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
}

.toggle-checkbox {
    appearance: none;
    width: 2.5rem;
    height: 1.25rem;
    background: #d1d5db;
    border-radius: 9999px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s;
}

.toggle-checkbox:checked {
    background: #3b82f6;
}

.toggle-checkbox::after {
    content: '';
    width: 1rem;
    height: 1rem;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    transition: transform 0.3s;
}

.toggle-checkbox:checked::after {
    transform: translateX(1.25rem);
}

/* Filter and Search */
.filter-search {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.dark .filter-search {
    background: #1f2937;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.custom-select, .custom-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.3s;
}

.custom-select:focus, .custom-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

body.dark .custom-select, body.dark .custom-input {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

/* Add/Edit Section */
.add-section, .edit-section {
    margin-top: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.section-title, .section-subtitle {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 1.5rem;
}

body.dark .section-title, body.dark .section-subtitle {
    color: #f3f4f6;
}

.section-subtitle {
    font-size: 1.25rem;
    font-weight: 500;
    color: #374151;
}

body.dark .section-subtitle {
    color: #d1d5db;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

body.dark .form-group label {
    color: #d1d5db;
}

.input-field, .input-file {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.3s;
}

.input-field:focus, .input-file:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

body.dark .input-field, body.dark .input-file {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

.rental-info-section {
    padding: 1.5rem;
    background: #f9fafb;
    border-radius: 8px;
    margin-top: 1.5rem;
}

body.dark .rental-info-section {
    background: #1f2937;
}

.link-section .link-entry {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 80px;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .link-section .link-entry {
        grid-template-columns: 1fr;
    }
}

/* CodeMirror Styles */
.CodeMirror {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    height: auto;
    min-height: 200px;
    font-size: 0.875rem;
    background: white;
}

body.dark .CodeMirror {
    background: #1f2937;
    border-color: #4b5563;
}

.CodeMirror-gutters {
    background: #f3f4f6;
}

body.dark .CodeMirror-gutters {
    background: #374151;
}

/* Preview Frame */
.preview-frame {
    width: 100%;
    height: 300px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-top: 1rem;
}

body.dark .preview-frame {
    border-color: #4b5563;
}

/* Functions Section */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.function-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

body.dark .function-card {
    background: #1f2937;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.function-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

body.dark .card-title {
    color: #f3f4f6;
}

.card-description {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 1rem;
}

body.dark .card-description {
    color: #9ca3af;
}

.card-link {
    display: inline-block;
    font-size: 0.875rem;
    color: #3b82f6;
    text-decoration: none;
    margin-bottom: 0.5rem;
}

.card-link:hover {
    text-decoration: underline;
}

.card-credentials {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 1rem;
}

body.dark .card-credentials {
    color: #9ca3af;
}

.card-credentials span {
    display: inline-block;
    margin-right: 1rem;
}

.card-image {
    max-width: 100%;
    border-radius: 6px;
    margin-bottom: 1rem;
    width: 100%;
    height: 300px;
}

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

/* Rental Details Section */
.rental-details {
    margin-top: 2rem;
}

.rental-section {
    padding: 1.5rem;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

body.dark .rental-section {
    background: #1f2937;
}

.link-item {
    padding: 0.75rem;
    border-left: 4px solid #3b82f6;
    background: white;
    border-radius: 6px;
}

body.dark .link-item {
    background: #374151;
}

.link-label {
    font-weight: 500;
    color: #1f2937;
}

body.dark .link-label {
    color: #f3f4f6;
}

.link-credentials {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

body.dark .link-credentials {
    color: #9ca3af;
}

.status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-hoàn-thành {
    background: #10b981;
    color: white;
}

.status-đang-phát-triển {
    background: #f59e0b;
    color: white;
}

.status-chưa-bắt-đầu {
    background: #ef4444;
    color: white;
}

.status-n-a {
    background: #6b7280;
    color: white;
}

.guide-text {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.5;
}

body.dark .guide-text {
    color: #9ca3af;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 50;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 1.5rem;
    width: 90%;
    max-width: 800px;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

body.dark .modal-content {
    background: #1f2937;
}

.close {
    float: right;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
}

body.dark .close {
    color: #9ca3af;
}

.tab-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-button {
    padding: 0.5rem 1rem;
    background: #e5e7eb;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
}

body.dark .tab-button {
    background: #374151;
    color: #e5e7eb;
}

.tab-button.tab-active {
    background: #3b82f6;
    color: white;
}

.tab-content {
    border: 1px solid #d1d5db;
    padding: 1rem;
    border-radius: 6px;
    max-height: 400px;
    overflow: auto;
}

body.dark .tab-content {
    border-color: #4b5563;
    background: #374151;
}

/* Login Form */
.login-form {
    max-width: 400px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body.dark .login-form {
    background: #1f2937;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .filter-search {
        flex-direction: column;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .modal-content, .rental-details, .edit-section {
        width: 95%;
        margin: 10% auto;
    }

    .rental-section .grid, .edit-section .grid {
        grid-template-columns: 1fr;
    }
}