/* Custom styles for Polaris */
/* Note: Using standard CSS since Tailwind CDN doesn't support @apply */

/* Color Palette */
:root {
    --amber-gold: #ffbf00;
    --magenta-bloom: #e83f6f;
    --rich-cerulean: #2274a5;
    --sea-green: #32936f;
    --white: #ffffff;

    /* Semantic colors */
    --color-primary: var(--rich-cerulean);
    --color-primary-hover: #1b5d84;
    --color-accent: var(--amber-gold);
    --color-accent-hover: #e6ac00;
    --color-sidebar: #1a1f2e;
    --color-sidebar-hover: #252b3d;

    /* Text colors */
    --color-text: var(--rich-cerulean);
    --color-text-dark: #1b5d84;
    --color-text-muted: #5a8ab5;
    --color-text-light: var(--white);

    /* Status colors */
    --color-success: var(--sea-green);
    --color-error: var(--magenta-bloom);
    --color-warning: var(--amber-gold);
}

/* Font family and base text color */
body {
    font-family: 'Inter', sans-serif;
    color: var(--color-text);
}

/* Navigation active state */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #d1d5db;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    text-decoration: none;
}

.nav-item:hover {
    background-color: var(--color-sidebar-hover);
    color: white;
}

.nav-item.active {
    background-color: var(--color-primary);
    color: white;
}

/* Cards */
.card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    padding: 1.5rem;
}

/* Metric cards */
.metric-card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-dark);
}

.metric-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.metric-change {
    font-size: 0.875rem;
    font-weight: 500;
}

.metric-change.positive {
    color: var(--color-success);
}

.metric-change.negative {
    color: var(--color-error);
}

/* Tables */
.data-table {
    width: 100%;
}

.data-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.875rem;
}

.data-table tr:hover {
    background-color: #f9fafb;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: background-color 0.15s;
    border: none;
    cursor: pointer;
}

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

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

.btn-secondary {
    background-color: #e5e7eb;
    color: var(--color-text-dark);
}

.btn-secondary:hover {
    background-color: #d1d5db;
}

/* Form inputs */
.input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(34, 116, 165, 0.2);
}

/* Toast notifications */
.toast {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    color: white;
    min-width: 16rem;
}

.toast.success {
    background-color: var(--color-success);
}

.toast.error {
    background-color: var(--color-error);
}

.toast.info {
    background-color: var(--color-primary);
}

/* Loading spinner */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Activity feed */
.activity-card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.activity-status {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.activity-status.done {
    background-color: #dcfce7;
    color: #166534;
}

.activity-status.in_progress {
    background-color: #fef9c3;
    color: #854d0e;
}

.activity-status.error {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Tab Navigation */
.tab-btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
    color: var(--color-text);
    border-bottom-color: #d1d5db;
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Trade Page Styles */

/* Action button states */
.action-btn {
    background-color: #e5e7eb;
    color: var(--color-text);
}

.action-btn:hover {
    background-color: #d1d5db;
}

.action-btn.active-buy {
    background-color: var(--color-success);
    color: white;
}

.action-btn.active-sell {
    background-color: var(--color-error);
    color: white;
}

/* Input mode toggle buttons */
.mode-btn {
    background-color: #f3f4f6;
    color: var(--color-text-muted);
    transition: background-color 0.15s, color 0.15s;
}

.mode-btn:hover {
    background-color: #e5e7eb;
}

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

/* Disabled button state */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover {
    background-color: inherit;
}

/* Stock row clickable styles */
.stock-row {
    cursor: pointer;
}

.stock-row:hover {
    background-color: rgba(34, 116, 165, 0.1);
}

/* Search dropdown */
#search-results {
    max-height: 300px;
    overflow-y: auto;
}

/* Success/Error animation */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#success-section,
#error-section {
    animation: fade-in 0.3s ease-out;
}

/* Status tabs for orders */
.status-tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.status-tab:hover {
    background-color: #e5e7eb;
}

.status-tab.active {
    background-color: var(--color-primary);
    color: white;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
}

.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.status-completed {
    background-color: #d1fae5;
    color: #065f46;
}

.status-cancelled,
.status-failed {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Portfolio tabs */
.portfolio-tab {
    padding: 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.portfolio-tab:hover {
    color: var(--color-text);
}

.portfolio-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Offline Banner */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #f59e0b;
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease-out;
}

.offline-banner.visible {
    transform: translateY(0);
}

/* Adjust app container when offline banner is visible */
body.offline #app {
    margin-top: 2.5rem;
    height: calc(100vh - 2.5rem);
}

/* Disabled state for offline-only actions */
.offline-disabled {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.offline-disabled::after {
    content: 'Requires connection';
    position: absolute;
    bottom: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Mobile Responsive */
@media (max-width: 767px) {
    /* Sidebar as drawer - !important needed to override Tailwind's -translate-x-full */
    #sidebar.open {
        transform: translateX(0) !important;
    }

    /* Show backdrop when drawer open */
    #drawer-backdrop.visible {
        display: block !important;
    }

    /* Adjust content padding */
    #content {
        padding: 1rem;
    }

    /* Stack metric cards */
    .metric-grid {
        grid-template-columns: 1fr;
    }

    /* Full-width cards */
    .card {
        margin-left: -1rem;
        margin-right: -1rem;
        border-radius: 0;
    }

    /* Larger touch targets */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }

    .nav-item {
        min-height: 48px;
        padding: 1rem;
    }

    .input {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Hide table columns on mobile */
    .hide-mobile {
        display: none;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
    #sidebar {
        width: 200px;
    }

    .nav-item span {
        font-size: 0.875rem;
    }
}
