/**
 * OVH Cloud Dashboard Styles
 *
 * Responsive design with dark mode support via [data-theme="dark"].
 * Follows admin panel design patterns.
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    min-height: 100vh;
}

.ovh-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 16px;
    position: relative;
}

/* ─── Tabs ──────────────────────────────────────────────────── */
.ovh-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ovh-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
    font-family: inherit;
}

.ovh-tab:hover {
    color: #2563eb;
}

.ovh-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.ovh-panel {
    display: none;
}

.ovh-panel.active {
    display: block;
}

/* ─── KPI Cards ─────────────────────────────────────────────── */
.ovh-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.ovh-kpi {
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
}

.ovh-kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.ovh-kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
}

/* ─── Section Title ─────────────────────────────────────────── */
.ovh-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #334155;
    margin: 20px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e2e8f0;
}

/* ─── Server Status Cards ───────────────────────────────────── */
.ovh-server-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.ovh-server-card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.ovh-server-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    border-color: #93c5fd;
}

.ovh-server-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ovh-server-card-name {
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
}

.ovh-server-card-info {
    font-size: 13px;
    color: #475569;
    line-height: 1.6;
}

.ovh-server-card-info span {
    display: block;
}

/* ─── Status Badge ──────────────────────────────────────────── */
.ovh-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ovh-badge-ok, .ovh-badge-green {
    background: #dcfce7;
    color: #166534;
}

.ovh-badge-warn, .ovh-badge-yellow {
    background: #fef9c3;
    color: #854d0e;
}

.ovh-badge-error, .ovh-badge-red {
    background: #fee2e2;
    color: #991b1b;
}

.ovh-badge-info, .ovh-badge-blue {
    background: #dbeafe;
    color: #1e40af;
}

.ovh-badge-grey {
    background: #f1f5f9;
    color: #475569;
}

/* ─── Renewal List ──────────────────────────────────────────── */
.ovh-renewal-list {
    display: grid;
    gap: 8px;
}

.ovh-renewal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 13px;
}

.ovh-renewal-name {
    font-weight: 500;
    color: #1e293b;
}

/* ─── Toolbar ───────────────────────────────────────────────── */
.ovh-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.ovh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.ovh-btn-primary {
    background: #2563eb;
    color: white;
}

.ovh-btn-primary:hover {
    background: #1d4ed8;
}

.ovh-btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

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

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

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

.ovh-btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ─── DataTables Overrides ──────────────────────────────────── */
table.dataTable thead th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #475569;
    letter-spacing: 0.3px;
    border-bottom: 2px solid #e2e8f0;
    padding: 10px 12px;
}

table.dataTable tbody td {
    font-size: 13px;
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

table.dataTable tbody tr:hover {
    background-color: #f8fafc !important;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px 8px;
}

.dataTables_wrapper .dataTables_info {
    font-size: 12px;
    color: #475569;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    font-size: 12px;
}

/* ─── Chart Container ───────────────────────────────────────── */
.ovh-chart-container {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    max-height: 350px;
}

.ovh-chart-container canvas {
    max-height: 300px;
}

/* ─── DNS Editor ────────────────────────────────────────────── */
.ovh-dns-editor {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid #e2e8f0;
}

.ovh-dns-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.ovh-dns-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.ovh-dns-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ─── Overlays ──────────────────────────────────────────────── */
.ovh-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
}

.ovh-overlay-box {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    max-height: 85vh;
    overflow-y: auto;
}

.ovh-overlay-box h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 12px;
}

.ovh-overlay-box p {
    color: #475569;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

.ovh-overlay-wide {
    max-width: 800px;
}

.ovh-overlay-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ─── Forms ─────────────────────────────────────────────────── */
.ovh-form-row {
    margin-bottom: 12px;
}

.ovh-form-row label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    margin-bottom: 4px;
}

.ovh-form-row input,
.ovh-form-row select,
.ovh-form-row textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    background: white;
}

.ovh-form-row input:focus,
.ovh-form-row select:focus,
.ovh-form-row textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ─── Ticket Detail ─────────────────────────────────────────── */
.ovh-ticket-detail {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid #e2e8f0;
}

.ovh-ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.ovh-ticket-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.ovh-ticket-messages {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.ovh-ticket-message {
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
}

.ovh-ticket-message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
    color: #475569;
}

.ovh-ticket-message-body {
    font-size: 14px;
    color: #1e293b;
    line-height: 1.5;
    white-space: pre-wrap;
}

.ovh-ticket-reply {
    display: grid;
    gap: 8px;
}

.ovh-ticket-reply textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
}

/* ─── Zone Export ────────────────────────────────────────────── */
.ovh-zone-export {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}

/* ─── Server Detail Content ─────────────────────────────────── */
.ovh-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.ovh-detail-item {
    padding: 8px 0;
}

.ovh-detail-label {
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.ovh-detail-value {
    font-size: 14px;
    color: #1e293b;
    word-break: break-all;
}

.ovh-detail-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.ovh-detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}

/* ─── Bandwidth chart in server detail ──────────────────────── */
.ovh-bw-chart-container {
    max-height: 250px;
    margin: 12px 0;
}

/* ─── Loading ───────────────────────────────────────────────── */
.ovh-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.ovh-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: ovh-spin 0.7s linear infinite;
}

@keyframes ovh-spin {
    to { transform: rotate(360deg); }
}

.ovh-loading-text {
    margin-top: 12px;
    font-size: 14px;
    color: #475569;
}

/* ─── Toast ─────────────────────────────────────────────────── */
.ovh-toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ovh-toast {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    animation: ovh-toast-in 0.3s ease;
    max-width: 400px;
}

.ovh-toast-success { background: #059669; }
.ovh-toast-error { background: #dc2626; }
.ovh-toast-info { background: #2563eb; }

@keyframes ovh-toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ─── Reverse DNS in overlay ────────────────────────────────── */
.ovh-rdns-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
}

.ovh-rdns-entry:last-child {
    border-bottom: none;
}

/* ─── Inline table action buttons ───────────────────────────── */
.ovh-table-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .ovh-container { padding: 8px; }
    .ovh-tabs { gap: 2px; }
    .ovh-tab { padding: 8px 12px; font-size: 12px; }
    .ovh-kpi-row { grid-template-columns: repeat(2, 1fr); }
    .ovh-kpi-value { font-size: 18px; }
    .ovh-server-cards { grid-template-columns: 1fr; }
    .ovh-detail-grid { grid-template-columns: 1fr; }
    .ovh-overlay-box { padding: 16px; }
    .ovh-dns-header { flex-direction: column; align-items: stretch; }
    .ovh-dns-actions { justify-content: flex-start; }
}

@media (max-width: 480px) {
    .ovh-kpi-row { grid-template-columns: 1fr; }
    .ovh-tab { padding: 6px 8px; font-size: 11px; }
}

/* ─── Dark Mode ─────────────────────────────────────────────── */
[data-theme="dark"] body {
    background: #0f172a;
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-tabs {
    border-bottom-color: #334155;
}

[data-theme="dark"] .ovh-tab {
    color: #94a3b8;
}

[data-theme="dark"] .ovh-tab:hover {
    color: #60a5fa;
}

[data-theme="dark"] .ovh-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

[data-theme="dark"] .ovh-kpi {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .ovh-kpi-label {
    color: #94a3b8;
}

[data-theme="dark"] .ovh-kpi-value {
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-section-title {
    color: #cbd5e1;
    border-bottom-color: #334155;
}

[data-theme="dark"] .ovh-server-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .ovh-server-card:hover {
    border-color: #3b82f6;
}

[data-theme="dark"] .ovh-server-card-name {
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-server-card-info {
    color: #94a3b8;
}

[data-theme="dark"] .ovh-renewal-item {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .ovh-renewal-name {
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-chart-container {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .ovh-btn-secondary {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}

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

[data-theme="dark"] .ovh-overlay {
    background: rgba(0,0,0,0.7);
}

[data-theme="dark"] .ovh-overlay-box {
    background: #1e293b;
}

[data-theme="dark"] .ovh-overlay-box h3 {
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-overlay-box p {
    color: #94a3b8;
}

[data-theme="dark"] .ovh-form-row label {
    color: #cbd5e1;
}

[data-theme="dark"] .ovh-form-row input,
[data-theme="dark"] .ovh-form-row select,
[data-theme="dark"] .ovh-form-row textarea {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-form-row input:focus,
[data-theme="dark"] .ovh-form-row select:focus,
[data-theme="dark"] .ovh-form-row textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .ovh-dns-editor {
    border-top-color: #334155;
}

[data-theme="dark"] .ovh-dns-header h3 {
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-ticket-detail {
    border-top-color: #334155;
}

[data-theme="dark"] .ovh-ticket-header h3 {
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-ticket-message {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .ovh-ticket-message-body {
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-ticket-reply textarea {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-loading {
    background: rgba(15, 23, 42, 0.8);
}

[data-theme="dark"] .ovh-spinner {
    border-color: #334155;
    border-top-color: #3b82f6;
}

[data-theme="dark"] .ovh-loading-text {
    color: #94a3b8;
}

[data-theme="dark"] .ovh-detail-label {
    color: #94a3b8;
}

[data-theme="dark"] .ovh-detail-value {
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-detail-section {
    border-top-color: #334155;
}

[data-theme="dark"] .ovh-detail-section h4 {
    color: #cbd5e1;
}

[data-theme="dark"] .ovh-rdns-entry {
    border-bottom-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .ovh-zone-export {
    background: #0f172a;
    color: #e2e8f0;
}

/* Dark mode badge overrides */
[data-theme="dark"] .ovh-badge-ok,
[data-theme="dark"] .ovh-badge-green {
    background: rgba(22, 163, 74, 0.2);
    color: #4ade80;
}

[data-theme="dark"] .ovh-badge-warn,
[data-theme="dark"] .ovh-badge-yellow {
    background: rgba(234, 179, 8, 0.2);
    color: #facc15;
}

[data-theme="dark"] .ovh-badge-error,
[data-theme="dark"] .ovh-badge-red {
    background: rgba(220, 38, 38, 0.2);
    color: #f87171;
}

[data-theme="dark"] .ovh-badge-info,
[data-theme="dark"] .ovh-badge-blue {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

[data-theme="dark"] .ovh-badge-grey {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

/* Dark mode DataTables */
[data-theme="dark"] table.dataTable thead th {
    color: #94a3b8;
    border-bottom-color: #334155;
}

[data-theme="dark"] table.dataTable tbody td {
    color: #e2e8f0;
    border-bottom-color: #1e293b;
}

[data-theme="dark"] table.dataTable tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.05) !important;
}

[data-theme="dark"] table.dataTable tbody tr {
    background-color: #0f172a;
}

[data-theme="dark"] table.dataTable {
    border-collapse: collapse;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_filter input {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_length select {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_info {
    color: #94a3b8;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #94a3b8 !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_length label,
[data-theme="dark"] .dataTables_wrapper .dataTables_filter label {
    color: #94a3b8;
}
