@import 'theme.css';

:root {
    --bg-black: #000000;
    --bg-dark: #0a0a0a;
    --bg-card: rgba(0, 0, 0, 0.4);
    --red-primary: #ef4444;
    --red-hover: #dc2626;
    --red-glow: rgba(239, 68, 68, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --border-color: rgba(255, 255, 255, 0.08);
    --green: #10b981;
    --blue: #3b82f6;
    --purple: #a855f7;
    --cyan: #06b6d4;
    --orange: #f97316;
}

body {
    background-color: var(--bg-black);
    color: var(--text-primary);
}

.background-gradient {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(239, 68, 68, 0.12), transparent 60%);
    pointer-events: none;
    z-index: -1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-black);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.background-gradient {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(239, 68, 68, 0.12), transparent 60%);
    pointer-events: none;
    z-index: 1;
}

.background-orbs {
    position: fixed;
    inset: 0;
    overflow: hidden;
    opacity: 0.25;
    pointer-events: none;
    z-index: 1;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--red-glow);
    top: -250px;
    right: -200px;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: var(--red-glow);
    bottom: -200px;
    left: -150px;
    animation-delay: -7s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: rgba(168, 85, 247, 0.2);
    top: 40%;
    left: 30%;
    animation-delay: -14s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -30px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

/* Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 50;
}

.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 32px 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    text-align: left;
    text-decoration: none;
}

.nav-item svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.nav-item:hover {
    background: rgba(239, 68, 68, 0.08);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
    color: var(--red-primary);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--red-primary), #dc2626);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-plan {
    font-size: 12px;
    color: var(--green);
    font-weight: 500;
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 32px 40px;
    min-height: 100vh;
}

/* Typography */
.gradient-text {
    background: linear-gradient(135deg, var(--red-primary), #f87171);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title h1 {
    font-size: 32px;
    font-weight: 900;
    margin-bottom: 4px;
}

.page-title p {
    color: var(--text-secondary);
    font-size: 15px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--red-primary), #dc2626);
    color: white;
    box-shadow: 0 4px 20px var(--red-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--red-glow);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red-primary);
}

.btn-danger-outline:hover {
    border-color: var(--red-primary);
    background: rgba(239, 68, 68, 0.1);
    color: var(--red-primary);
}

.btn-sm {
    padding: 10px 20px;
    font-size: 13px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 15px;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Cards */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 28px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    margin-bottom: 24px;
}

.glass-card:hover {
    border-color: rgba(239, 68, 68, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Device Cards */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.device-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.device-card:hover {
    border-color: rgba(239, 68, 68, 0.3);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.device-card.active {
    border-color: rgba(16, 185, 129, 0.3);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), transparent);
}

.device-card.active:hover {
    border-color: var(--green);
}

.device-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.device-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    color: var(--red-primary);
}

.device-card.active .device-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--green);
}

.device-info h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.device-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.device-status {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.device-status.online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--green) !important;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.device-status.offline {
    background: rgba(156, 163, 175, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.device-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.device-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.device-meta-item {
    font-size: 12px;
}

.device-meta-item span {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.device-meta-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Add Device Card */
.add-device-card {
    border: 2px dashed var(--border-color);
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    cursor: pointer;
    transition: all 0.3s;
}

.add-device-card:hover {
    border-color: var(--red-primary);
    background: rgba(239, 68, 68, 0.02);
}

.add-device-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(239, 68, 68, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--red-primary);
    margin-bottom: 16px;
    transition: all 0.3s;
}

.add-device-card:hover .add-device-icon {
    background: var(--red-primary);
    color: white;
    transform: scale(1.1);
}

.add-device-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}

.add-device-card:hover .add-device-text {
    color: var(--text-primary);
}

/* Subscription Info */
.subscription-banner {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(168, 85, 247, 0.05));
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.subscription-info h2 {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 4px;
}

.subscription-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

.subscription-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 20px;
    color: var(--green);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.subscription-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--green);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Polar.sh Integration */
.polar-checkout-btn {
    background: #18181b;
    color: white;
    border: 1px solid #27272a;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.polar-checkout-btn:hover {
    background: #27272a;
    border-color: #3f3f46;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    transform: scale(0.9);
    transition: all 0.3s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 8px;
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.3s;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--red-primary);
    box-shadow: 0 0 0 4px var(--red-glow);
    background: rgba(255, 255, 255, 0.05);
}

.form-input::placeholder {
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Notification */
.notification {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 4px solid var(--green);
    border-radius: 12px;
    padding: 16px 24px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    z-index: 9999;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification.error {
    border-left-color: var(--red-primary);
}

/* Page Transitions */
.page {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .devices-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .dashboard-layout {
        flex-direction: column;
    }

    .devices-grid {
        grid-template-columns: 1fr;
    }

    .subscription-banner {
        flex-direction: column;
        text-align: center;
    }
}

/* ====== PLAN SELECTION UI ====== */
.plan-selector {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.plan-option {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    user-select: none;
}

.plan-option:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

.plan-option.selected {
    border-color: var(--red-primary);
    background: rgba(239, 68, 68, 0.05);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.1);
}

.plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.plan-name {
    font-weight: 700;
    font-size: 14px;
    color: white;
}

.plan-badge {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    background: var(--green);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
}

.plan-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 8px;
}

.plan-price .price {
    font-size: 24px;
    font-weight: 800;
    color: white;
}

.plan-price .period {
    font-size: 13px;
    color: var(--text-secondary);
}

.plan-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Mobile responsivness for plan selector */
@media (max-width: 600px) {
    .plan-selector {
        flex-direction: column;
        gap: 12px;
    }
}