/* gozone - PowerDNS Admin Interface Styles */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-hover: #334155;
    --sidebar-width: 220px;
    --sidebar-collapsed-width: 52px;
}

[data-theme="dark"] {
    color-scheme: dark;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #94a3b8;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #fbbf24;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --sidebar-bg: #0b1322;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #1e293b;
}

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

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

/* Sidebar layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: width 0.25s ease;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--sidebar-hover);
    min-height: 56px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius);
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.sidebar-toggle:hover {
    color: #f1f5f9;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-brand a {
    color: var(--primary);
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
    line-height: 1.2;
}

.sidebar-brand .nav-subtitle {
    font-size: 0.65rem;
    color: var(--sidebar-text);
    line-height: 1.2;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    padding-left: calc(0.75rem + 28px + 0.5rem);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.nav-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 1.2rem;
    text-align: center;
}

.nav-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #f1f5f9;
}

.sidebar-nav a.active {
    background: var(--sidebar-hover);
    color: #f1f5f9;
    border-left-color: var(--primary);
}

.sidebar-footer {
    padding: 0.75rem;
    padding-left: calc(0.75rem + 28px + 0.5rem);
    border-top: 1px solid var(--sidebar-hover);
    font-size: 0.8rem;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-footer .username {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
    color: inherit;
}

.sidebar-footer .username:hover {
    color: var(--primary);
}

.sidebar-footer .btn-logout {
    background: none;
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    padding: 0.15rem 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    color: var(--danger) !important;
    text-decoration: none;
    flex-shrink: 0;
    transition: all 0.2s;
}

.sidebar-footer .btn-logout:hover {
    background: var(--danger);
    color: #fff !important;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    background: var(--bg);
    transition: margin-left 0.25s ease;
}

/* Collapsed sidebar */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-header {
    padding: 0.5rem;
    justify-content: center;
}

body.sidebar-collapsed .sidebar-brand {
    display: none;
}

body.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 0.6rem 0.5rem;
    gap: 0;
}

body.sidebar-collapsed .nav-icon {
    font-size: 1rem;
}

body.sidebar-collapsed .nav-text {
    display: none;
}

body.sidebar-collapsed .sidebar-nav a:hover::after {
    content: attr(title);
    position: fixed;
    left: calc(var(--sidebar-collapsed-width) + 8px);
    background: var(--sidebar-bg);
    color: #f1f5f9;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 300;
    box-shadow: var(--shadow);
}

body.sidebar-collapsed .sidebar-footer {
    padding: 0.5rem;
    justify-content: center;
    padding-left: 0.5rem;
    flex-direction: column;
    gap: 0.35rem;
}

body.sidebar-collapsed .sidebar-footer .username {
    display: none;
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.15rem 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    color: var(--text);
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg);
}

.theme-toggle-fixed {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 200;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.breadcrumb {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
}

.breadcrumb:hover {
    text-decoration: underline;
}

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

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #334155;
}

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

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

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table-responsive .table {
    margin-bottom: 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.4rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    word-break: break-word;
    overflow-wrap: break-word;
    font-size: 0.8125rem;
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg);
}

.table tr:hover {
    background: #f8fafc;
}

[data-theme="dark"] .table tr:hover {
    background: #1a2332;
}

.table a {
    color: var(--primary);
    text-decoration: none;
}

.table a:hover {
    text-decoration: underline;
}

.table .actions-cell {
    white-space: nowrap;
}

.nowrap {
    white-space: nowrap;
}

/* Metadata */
.meta-value {
    display: inline-block;
    margin: 0.1rem 0.25rem 0.1rem 0;
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.empty-meta {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0.75rem 0;
}

details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
}

.mono {
    font-family: monospace;
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
    background: var(--bg);
    color: var(--text-muted);
}

.badge-active {
    background: #dcfce7;
    color: var(--success);
}

.badge-disabled {
    background: #fee2e2;
    color: var(--danger);
}

.badge-admin {
    background: #dbeafe;
    color: var(--primary);
}

.badge-user {
    background: var(--bg);
    color: var(--text-muted);
}

.badge-type {
    background: #ede9fe;
    color: #7c3aed;
}

/* Record type colors (light mode) */
.badge-type-A       { background: #dbeafe; color: #1d40e8; }
.badge-type-AAAA    { background: #ede9fe; color: #7c3aed; }
.badge-type-ALIAS   { background: #e0f2fe; color: #0369a1; }
.badge-type-CAA     { background: #dcfce7; color: #15803d; }
.badge-type-CNAME   { background: #ffedd5; color: #c2410c; }
.badge-type-DNSKEY  { background: #f5f5f4; color: #57534e; }
.badge-type-DS      { background: #f5f5f4; color: #78716c; }
.badge-type-HINFO   { background: #fef9c3; color: #a16207; }
.badge-type-KEY     { background: #f5f5f4; color: #44403c; }
.badge-type-LOC     { background: #ecfccb; color: #4d7c0f; }
.badge-type-MX      { background: #fce7f3; color: #be185d; }
.badge-type-NAPTR   { background: #f5f5f4; color: #737373; }
.badge-type-NS      { background: #cffafe; color: #0e7490; }
.badge-type-NSEC    { background: #f5f5f4; color: #737373; }
.badge-type-NSEC3   { background: #f5f5f4; color: #78716c; }
.badge-type-PTR     { background: #fee2e2; color: #b91c1c; }
.badge-type-RRSIG   { background: #f5f5f4; color: #a3a3a3; }
.badge-type-SOA     { background: #fef3c7; color: #b45309; }
.badge-type-SRV     { background: #e0e7ff; color: #4338ca; }
.badge-type-SSHFP   { background: #f5f5f4; color: #57534e; }
.badge-type-TXT     { background: #d1fae5; color: #047857; }

/* Record type colors (dark mode) */
[data-theme="dark"] .badge-type-A       { background: rgba(37,99,235,0.18); color: #93c5fd; }
[data-theme="dark"] .badge-type-AAAA    { background: rgba(124,58,237,0.18); color: #a78bfa; }
[data-theme="dark"] .badge-type-ALIAS   { background: rgba(3,105,161,0.18); color: #7dd3fc; }
[data-theme="dark"] .badge-type-CAA     { background: rgba(22,163,74,0.18); color: #4ade80; }
[data-theme="dark"] .badge-type-CNAME   { background: rgba(194,65,12,0.18); color: #fb923c; }
[data-theme="dark"] .badge-type-DNSKEY  { background: rgba(87,83,78,0.2); color: #d6d3d1; }
[data-theme="dark"] .badge-type-DS      { background: rgba(120,113,108,0.2); color: #d6d3d1; }
[data-theme="dark"] .badge-type-HINFO   { background: rgba(161,98,7,0.18); color: #fde047; }
[data-theme="dark"] .badge-type-KEY     { background: rgba(68,64,60,0.2); color: #d6d3d1; }
[data-theme="dark"] .badge-type-LOC     { background: rgba(77,124,15,0.18); color: #a3e635; }
[data-theme="dark"] .badge-type-MX      { background: rgba(190,24,93,0.18); color: #f472b6; }
[data-theme="dark"] .badge-type-NAPTR   { background: rgba(115,115,115,0.2); color: #d4d4d4; }
[data-theme="dark"] .badge-type-NS      { background: rgba(14,116,144,0.18); color: #22d3ee; }
[data-theme="dark"] .badge-type-NSEC    { background: rgba(115,115,115,0.2); color: #d4d4d4; }
[data-theme="dark"] .badge-type-NSEC3   { background: rgba(120,113,108,0.2); color: #d6d3d1; }
[data-theme="dark"] .badge-type-PTR     { background: rgba(185,28,28,0.18); color: #f87171; }
[data-theme="dark"] .badge-type-RRSIG   { background: rgba(163,163,163,0.15); color: #d4d4d4; }
[data-theme="dark"] .badge-type-SOA     { background: rgba(180,83,9,0.18); color: #fbbf24; }
[data-theme="dark"] .badge-type-SRV     { background: rgba(67,56,202,0.18); color: #818cf8; }
[data-theme="dark"] .badge-type-SSHFP   { background: rgba(87,83,78,0.2); color: #d6d3d1; }
[data-theme="dark"] .badge-type-TXT     { background: rgba(4,120,87,0.18); color: #34d399; }

.badge-create_zone,
.badge-create_record {
    background: #dcfce7;
    color: var(--success);
}

.badge-delete_zone,
.badge-delete_record {
    background: #fee2e2;
    color: var(--danger);
}

.badge-login,
.badge-logout {
    background: var(--bg);
    color: var(--text-muted);
}

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.form-group small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    transition: border-color 0.2s;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.input-row textarea.form-control,
.input-row .form-control {
    flex: 1;
}

.input-row .btn {
    min-width: 6rem;
    height: auto;
}

.search-form {
    display: inline-flex;
}

.search-input {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    min-width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.form-control-inline {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--primary);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    width: 100%;
    box-sizing: border-box;
}

.form-control-inline:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.records-table td {
    vertical-align: top;
}

.records-table .col-name {
    min-width: 10rem;
    max-width: 18rem;
    white-space: nowrap;
}

.records-table .col-prio {
    white-space: nowrap;
    width: 1%;
}

.ev-prio {
    min-width: 4rem;
    width: 4rem;
}

.ev-content {
    min-width: 12rem;
    box-sizing: border-box;
}

.ev-ttl {
    min-width: 5rem;
    width: 5rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #dcfce7;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-box {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 2.5rem;
}

.login-box h1 {
    text-align: center;
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

/* Zone Meta */
.zone-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

/* Actions Row */
.actions-row {
    display: flex;
    gap: 0.75rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* Profile */
.profile-info p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

/* Server Info */
.server-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.server-info-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.server-info-label {
    font-weight: 600;
    flex: 0 0 12rem;
    color: var(--text-muted);
}

/* API Keys */
.api-key-reveal {
    margin-top: 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.api-key-reveal pre {
    flex: 1;
    background: #1e293b;
    color: #a5f3fc;
    padding: 0.75rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.8125rem;
    line-height: 1.5;
    margin: 0;
}

.api-key-reveal pre code {
    word-break: break-all;
    white-space: pre-wrap;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.page-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination .disabled {
    opacity: 0.4;
    pointer-events: none;
}

.per-page-select {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    body:not(.sidebar-collapsed) .sidebar {
        width: var(--sidebar-width);
        box-shadow: 4px 0 12px rgba(0,0,0,0.2);
    }

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .container {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}
