/* Reset and Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --success: #16a34a;
    --warning: #d97706;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
}

/* Typography */
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.25rem; font-weight: 600; }

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
}

.navbar-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}
.navbar-brand a:hover { text-decoration: none; }

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--gray-600);
    font-weight: 500;
}
.nav-link:hover { color: var(--gray-900); text-decoration: none; }
.nav-link.active { color: var(--primary); }

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    color: var(--gray-700);
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: var(--danger-dark); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-100); }

.btn-danger.btn-outline {
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger.btn-outline:hover {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-block { width: 100%; }

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group.has-error input {
    border-color: var(--danger);
}

.form-group .hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.form-group .error-message {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--danger);
}

/* Alerts */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-trial {
    background: #dbeafe;
    color: var(--primary);
}

.badge-success {
    background: #dcfce7;
    color: var(--success);
}

.badge-warning {
    background: #fef3c7;
    color: var(--warning);
}

.badge-danger {
    background: #fee2e2;
    color: var(--danger);
}

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.auth-box {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--gray-500);
}

.trial-notice {
    background: #dbeafe;
    color: var(--primary);
    padding: 0.75rem;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
    color: var(--gray-500);
}

.forgot-link {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    margin: 0;
}

.breadcrumb {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.breadcrumb a {
    color: var(--gray-500);
}

.page-actions {
    display: flex;
    gap: 0.5rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h2 {
    margin-bottom: 0.5rem;
    color: var(--gray-700);
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

.empty-state-small {
    padding: 1.5rem;
    background: var(--gray-100);
    border-radius: var(--radius);
    text-align: center;
    color: var(--gray-500);
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.15s;
}

.project-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.project-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.project-platform {
    font-size: 1.5rem;
}

.project-header h3 {
    margin: 0;
    color: var(--gray-900);
}

.project-description {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.project-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tool-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    background: var(--gray-100);
    color: var(--gray-600);
    text-transform: capitalize;
}

.tool-badge.tool-planning { background: #dbeafe; color: #1e40af; }
.tool-badge.tool-crashes { background: #fee2e2; color: #991b1b; }
.tool-badge.tool-none { background: var(--gray-100); color: var(--gray-400); }

.project-meta {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Modal */
.modal {
    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: 1000;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 1rem;
}

.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-600);
}

.modal-content form,
.modal-content > p {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* Subscription Offer */
.subscription-offer {
    text-align: center;
    padding: 1.5rem;
}

.subscription-offer .plan-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.subscription-offer .plan-price {
    font-size: 1.5rem;
    color: var(--gray-700);
    margin-bottom: 1rem;
}

.subscription-offer .plan-price strong {
    font-size: 2.5rem;
    color: var(--primary);
}

.subscription-offer .plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
    text-align: left;
    display: inline-block;
}

.subscription-offer .plan-features li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--gray-600);
}

.subscription-offer .plan-features li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

#paypal-button-container {
    max-width: 300px;
    margin: 0 auto;
}

/* Project Detail */
.project-detail {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.project-info {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.project-meta-row {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-100);
}

.meta-item {
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* Tools Section */
.tools-section,
.api-keys-section {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.section-description {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.tool-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.tool-card.tool-coming-soon {
    opacity: 0.6;
}

.tool-icon {
    font-size: 2rem;
}

.tool-info {
    flex: 1;
}

.tool-info h3 {
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.tool-info p {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin: 0;
}

.coming-soon-badge {
    display: inline-block;
    margin-top: 0.25rem;
    font-size: 0.625rem;
    color: var(--warning);
    text-transform: uppercase;
    font-weight: 600;
}

.tool-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tool-open-btn {
    white-space: nowrap;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: 0.2s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

input:disabled + .slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* API Keys */
.api-keys-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.api-key-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.api-key-info code {
    margin-left: 0.5rem;
    background: var(--gray-200);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.api-key-meta {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Settings */
.settings-grid {
    display: grid;
    gap: 2rem;
}

.settings-section {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.settings-section h2 {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-100);
}

.subscription-card {
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.subscription-status {
    margin-bottom: 1rem;
}

.status-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: capitalize;
}

.subscription-details {
    margin-bottom: 1rem;
}

.subscription-details p {
    margin-bottom: 0.25rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--gray-400);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .navbar-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .container {
        padding: 1rem;
    }

    .project-meta-row {
        flex-direction: column;
        gap: 0.5rem;
    }
}
