/* Custom styles for DNS System */

/* 防止移动端横向滚动 */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* 确保所有元素不超出视口 */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Smooth transitions */
* {
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Dark mode scrollbar */
.dark ::-webkit-scrollbar-track {
    background: #374151;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Focus styles */
input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: none;
    box-shadow: 0 0 0 2px #e5e7eb;
}

.dark input:focus,
.dark select:focus,
.dark textarea:focus,
.dark button:focus {
    box-shadow: 0 0 0 2px #4b5563;
}

/* ==================== Dark Mode Global Styles ==================== */

/* 卡片和容器 */
.dark .bg-white {
    background-color: #1f2937 !important;
}

.dark .bg-gray-50 {
    background-color: #111827 !important;
}

.dark .bg-gray-100 {
    background-color: #1f2937 !important;
}

/* 文字颜色 */
.dark .text-gray-900 {
    color: #f9fafb !important;
}

.dark .text-gray-800 {
    color: #f3f4f6 !important;
}

.dark .text-gray-700 {
    color: #e5e7eb !important;
}

.dark .text-gray-600 {
    color: #d1d5db !important;
}

.dark .text-gray-500 {
    color: #9ca3af !important;
}

.dark .text-gray-400 {
    color: #9ca3af !important;
}

/* 边框颜色 */
.dark .border-gray-200 {
    border-color: #374151 !important;
}

.dark .border-gray-100 {
    border-color: #374151 !important;
}

.dark .border-gray-300 {
    border-color: #4b5563 !important;
}

.dark .divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
    border-color: #374151 !important;
}

.dark .divide-gray-100 > :not([hidden]) ~ :not([hidden]) {
    border-color: #374151 !important;
}

/* 表单输入框 */
.dark input,
.dark select,
.dark textarea {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #f3f4f6 !important;
}

.dark input::placeholder,
.dark textarea::placeholder {
    color: #9ca3af !important;
}

.dark input:disabled,
.dark select:disabled,
.dark textarea:disabled {
    background-color: #1f2937 !important;
    color: #6b7280 !important;
}

/* 表格 */
.dark table {
    background-color: #1f2937;
}

.dark thead {
    background-color: #374151 !important;
}

.dark th {
    color: #e5e7eb !important;
    border-color: #4b5563 !important;
}

.dark td {
    color: #d1d5db !important;
    border-color: #374151 !important;
}

.dark tbody tr:hover {
    background-color: #374151 !important;
}

.dark .hover\:bg-gray-50:hover {
    background-color: #374151 !important;
}

/* 按钮 */
.dark .bg-gray-900 {
    background-color: #4b5563 !important;
}

.dark .hover\:bg-gray-800:hover {
    background-color: #374151 !important;
}

.dark .bg-gray-200 {
    background-color: #4b5563 !important;
}

.dark .hover\:bg-gray-100:hover {
    background-color: #374151 !important;
}

/* 徽章和标签 */
.dark .bg-green-100 {
    background-color: rgba(34, 197, 94, 0.2) !important;
}

.dark .bg-red-100 {
    background-color: rgba(239, 68, 68, 0.2) !important;
}

.dark .bg-yellow-100 {
    background-color: rgba(234, 179, 8, 0.2) !important;
}

.dark .bg-blue-100 {
    background-color: rgba(59, 130, 246, 0.2) !important;
}

.dark .bg-purple-100 {
    background-color: rgba(168, 85, 247, 0.2) !important;
}

.dark .bg-indigo-100 {
    background-color: rgba(99, 102, 241, 0.2) !important;
}

/* 阴影 */
.dark .shadow,
.dark .shadow-sm,
.dark .shadow-md,
.dark .shadow-lg {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px -1px rgba(0, 0, 0, 0.3) !important;
}

/* 环形边框 */
.dark .ring-1 {
    --tw-ring-color: #374151 !important;
}

/* 分割线 */
.dark hr {
    border-color: #374151 !important;
}

/* 代码块 */
.dark code {
    background-color: #374151 !important;
    color: #f3f4f6 !important;
}

.dark pre {
    background-color: #1f2937 !important;
    color: #f3f4f6 !important;
}

/* 弹窗/模态框 */
.dark [class*="modal"],
.dark [x-show*="show"] .bg-white {
    background-color: #1f2937 !important;
}

/* 下拉菜单 */
.dark [x-show] ul,
.dark [x-show] .bg-white {
    background-color: #1f2937 !important;
}

/* 选中状态 */
.dark ::selection {
    background-color: #4b5563;
    color: #f9fafb;
}

/* ==================== End Dark Mode ==================== */

/* Table styles */
table {
    border-collapse: collapse;
    width: 100%;
}

/* Loading spinner */
.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Modal backdrop */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* Button hover effects */
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Card hover effects */
.card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Form input placeholder */
::placeholder {
    color: #9ca3af;
}

/* Selection color */
::selection {
    background-color: #e5e7eb;
    color: #111827;
}

/* Hide elements with x-cloak before Alpine.js loads */
[x-cloak] {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* 表格在移动端可横向滚动 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 防止长文本溢出 */
    .truncate-mobile {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* 移动端表单输入框 */
    input, select, textarea {
        max-width: 100%;
    }
    
    /* 移动端按钮组 */
    .btn-group-mobile {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Animation for fade in */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide up animation */
.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
