/* UniFi Toolkit - Main Dashboard Styles */

:root {
    /* Crosstalk Solutions Brand Colors */
    --ct-blue: #2B3990;
    --ct-orange: #F15A29;
    --ct-grey: #939598;

    /* Light Mode (default) */
    --primary-color: #2B3990;
    --accent-color: #F15A29;
    --secondary-color: #939598;
    --success-color: #10b981;
    --background: #f9fafb;
    --surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Dark Mode - applied when data-theme="dark" is set on html element */
:root[data-theme="dark"] {
    --primary-color: #4B5FBB;
    --accent-color: #F15A29;
    --secondary-color: #939598;
    --success-color: #10b981;
    --background: #0f172a;
    --surface: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

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

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

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

/* Header */
.header {
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-left {
    flex: 1;
    display: flex;
    align-items: center;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.header-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.header-logo {
    max-height: 40px;
    width: auto;
}

.header h1 {
    font-size: 1.75rem;
    margin: 0;
    color: var(--text-primary);
    white-space: nowrap;
}

/* System Status Widget */
.system-status {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    cursor: pointer;
}

.status-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    flex: 1;
    justify-content: center;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-icon {
    font-size: 1.25rem;
}

.status-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-expand-btn:hover {
    background: var(--border-color);
}

.status-expand-btn.expanded #expand-icon {
    transform: rotate(180deg);
}

#expand-icon {
    transition: transform 0.3s ease;
    display: inline-block;
}

/* Status Details (Accordion Content) */
.status-details {
    display: none;
    padding: 0 1.5rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.status-details.expanded {
    display: block;
}

.status-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding-top: 1rem;
}

.detail-card {
    background: var(--background);
    border-radius: 8px;
    padding: 1rem;
}

.detail-card h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.detail-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.detail-row span:first-child {
    color: var(--text-secondary);
}

.detail-row span:last-child {
    font-weight: 500;
    color: var(--text-primary);
}

/* WAN IP obfuscation - click to reveal */
.wan-ip-hidden {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.wan-ip-hidden:hover {
    color: var(--accent-color);
}

.wan-ip-hidden[data-revealed="true"] {
    cursor: default;
    user-select: text;
}

.health-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.health-badge.ok {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.health-badge.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.health-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.health-label-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.health-reason {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
}

.health-reason:not(:empty)::before {
    content: "(";
}

.health-reason:not(:empty)::after {
    content: ")";
}

/* Detail card header */
.detail-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.detail-card-header h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    padding: 0;
    border: none;
}

/* Loading and Error States */
.status-loading,
.status-error {
    display: none;
    padding: 1rem 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}

.status-loading.visible {
    display: block;
}

.status-error.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.status-header.hidden {
    display: none;
}

.configure-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

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

/* Responsive Status Widget */
@media (max-width: 768px) {
    .status-summary {
        gap: 0.75rem;
    }

    .status-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.125rem;
    }

    .status-icon {
        display: none;
    }

    .status-details-grid {
        grid-template-columns: 1fr;
    }
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.tool-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.tool-card-coming-soon {
    opacity: 0.6;
}

.tool-card-coming-soon:hover {
    transform: none;
}

.tool-icon {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 1rem;
    height: 80px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-icon-image {
    text-align: center;
    height: 80px;
    margin-bottom: 1rem;
    display: block;
}

.tool-icon-image img {
    max-width: 280px;
    height: 80px;
    width: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.tool-card h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    text-align: center;
}

.tool-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    flex-grow: 1;
    font-size: 1rem;
    line-height: 1.6;
}

.tool-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.feature-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.feature-badge-disabled {
    background: var(--secondary-color);
}

.tool-bottom {
    margin-top: auto;
}

.tool-actions {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.tool-version {
    text-align: right;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Tool Unavailable State */
.tool-unavailable {
    opacity: 0.7;
    position: relative;
}

.tool-unavailable:hover {
    transform: none;
}

.tool-unavailable::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(139, 92, 246, 0.03) 10px,
        rgba(139, 92, 246, 0.03) 20px
    );
    pointer-events: none;
    border-radius: 12px;
}

:root[data-theme="dark"] .tool-unavailable::after {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(139, 92, 246, 0.05) 10px,
        rgba(139, 92, 246, 0.05) 20px
    );
}

.tool-status {
    margin-top: auto;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    color: #92400e;
    font-size: 0.8rem;
    line-height: 1.4;
    text-align: center;
}

/* Success/info state for IDS active message */
.tool-status.status-success {
    background: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

:root[data-theme="dark"] .tool-status.status-success {
    background: #064e3b;
    border-color: #059669;
    color: #6ee7b7;
}

:root[data-theme="dark"] .tool-status {
    background: #422006;
    border-color: #78350f;
    color: #fbbf24;
}

.tool-status strong {
    display: inline;
}

.tool-status .check-again {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: inherit;
    opacity: 0.8;
    cursor: pointer;
    text-decoration: underline;
}

.tool-status .check-again:hover {
    opacity: 1;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
}

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

.btn-primary:hover {
    background: #1e2d75;
    transform: translateY(-1px);
}

:root[data-theme="dark"] .btn-primary:hover {
    background: #5b6fc9;
}

.btn-disabled,
.btn.disabled {
    background: var(--secondary-color);
    color: white;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn.disabled:hover {
    transform: none;
    background: var(--secondary-color);
}

/* Info Section */
.info-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.info-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.info-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.info-card p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.info-card ol,
.info-card ul {
    margin-left: 1.5rem;
    color: var(--text-secondary);
}

.info-card li {
    margin-bottom: 0.5rem;
}

/* Promo Banner */
.promo-banner {
    max-width: 800px;
    margin: 0 auto 2rem;
    text-align: center;
}

.promo-banner a {
    display: block;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.promo-banner a:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.promo-banner img {
    width: 100%;
    height: auto;
    display: block;
}

@media (max-width: 768px) {
    .promo-banner {
        margin: 0 0 1.5rem;
    }
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

.footer p {
    margin-bottom: 0.5rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

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

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-disclaimer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: 1rem;
}

.donate-link {
    color: var(--accent-color) !important;
}

.donate-link:hover {
    opacity: 0.8;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Settings Button */
.settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.25rem;
}

.settings-btn:hover {
    background: var(--border-color);
    transform: scale(1.05);
}

.settings-icon {
    font-size: 1.25rem;
}

/* Logout Button */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.logout-icon {
    font-size: 1rem;
}

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

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.25rem;
}

.theme-toggle-btn:hover {
    background: var(--border-color);
    transform: scale(1.05);
}

.theme-toggle-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}


/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header {
        padding: 0.75rem 1rem;
    }

    .header-content {
        flex-wrap: wrap;
    }

    .header-left {
        order: 1;
        flex: 0 0 auto;
    }

    .header-center {
        order: 3;
        flex: 1 1 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }

    .header-right {
        order: 2;
        flex: 0 0 auto;
    }

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

    .header-logo {
        max-height: 32px;
    }

    .tools-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .info-section {
        grid-template-columns: 1fr;
    }

    .theme-toggle-label {
        display: none;
    }

    .logout-label {
        display: none;
    }

    .logout-btn {
        padding: 0.5rem;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

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

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

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--background);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

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

.auth-info-box {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.auth-info-box strong {
    color: var(--text-primary);
}

.auth-info-box p {
    margin: 0.5rem 0 0 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.message.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

:root[data-theme="dark"] .message.success {
    background: #064e3b;
    color: #d1fae5;
}

:root[data-theme="dark"] .message.error {
    background: #7f1d1d;
    color: #fee2e2;
}

:root[data-theme="dark"] .message.info {
    background: #1e3a8a;
    color: #dbeafe;
}

@media (max-width: 768px) {
    .modal-content {
        max-width: 100%;
        margin: 1rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}
