* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0071E3;
    --primary-dark: #0051b3;
    --secondary: #00D4FF;
    --success: #34C759;
    --danger: #FF3B30;
    --warning: #FF9500;
    --background: #f5f5f7;
    --surface: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --border: #d2d2d7;
    --shadow: rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 40px 20px;
    border-radius: var(--radius);
    margin-bottom: 30px;
    box-shadow: 0 10px 30px var(--shadow);
}

.header-content {
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: var(--surface);
    padding: 10px;
    border-radius: var(--radius);
    box-shadow: 0 2px 10px var(--shadow);
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn:hover {
    background: var(--background);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

.tab-btn span {
    font-size: 1.2rem;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

.form-container {
    background: var(--surface);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: 0 2px 20px var(--shadow);
}

.form-container h2 {
    font-size: 2rem;
    margin-bottom: 30px;
    color: var(--text);
}

.form-section {
    margin-bottom: 40px;
    padding-bottom: 40px;
    border-bottom: 1px solid var(--border);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.template-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.template-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--shadow);
}

.template-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.1) 0%, rgba(0, 212, 255, 0.1) 100%);
}

.template-card.selected::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.template-card h4 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--text);
}

.template-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.color-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-input-group input[type="color"] {
    width: 60px;
    height: 40px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

.color-input-group .color-text {
    flex: 1;
    padding: 8px 12px;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: monospace;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px var(--shadow);
}

.btn-secondary {
    background: var(--background);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.form-actions {
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

.form-actions .btn {
    min-width: 250px;
    justify-content: center;
    font-size: 1.1rem;
}

.list-container {
    background: var(--surface);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: 0 2px 20px var(--shadow);
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.list-header h2 {
    font-size: 2rem;
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.page-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.3s ease;
    background: var(--surface);
}

.page-card:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 30px var(--shadow);
    transform: translateY(-5px);
}

.page-card-header {
    margin-bottom: 15px;
}

.page-card-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.page-card-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.page-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-template {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-visits {
    background: #f3e5f5;
    color: #7b1fa2;
}

.badge-active {
    background: #e8f5e9;
    color: #388e3c;
}

.page-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.page-card-actions .btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 0.9rem;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 30px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--background);
    color: var(--text);
}

.modal-body {
    padding: 30px;
}

.detail-group {
    margin-bottom: 20px;
}

.detail-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.detail-group .value {
    padding: 10px;
    background: var(--background);
    border-radius: 6px;
    word-wrap: break-word;
}

.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 30px var(--shadow);
    z-index: 2000;
    transition: all 0.3s ease;
    min-width: 300px;
    text-align: center;
}

.toast.show {
    bottom: 30px;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        padding: 30px 20px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .form-container,
    .list-container {
        padding: 20px;
    }

    .nav-tabs {
        flex-direction: column;
    }

    .template-grid,
    .pages-grid {
        grid-template-columns: 1fr;
    }

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

    .page-card-actions {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

.hidden {
    display: none !important;
}
