/* ============================================================
   SaaS Voting & Polling Online — Custom Styles
   Tailwind CSS is loaded via CDN; this file adds custom overrides
   ============================================================ */

:root {
    --vp-primary: #6d28d9;
    --vp-primary-dark: #5b21b6;
    --vp-primary-light: #ede9fe;
    --vp-accent: #f59e0b;
    --vp-success: #10b981;
    --vp-danger: #ef4444;
    --vp-bg: #f3f4f6;
}

/* Base */
html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--vp-bg);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--vp-primary);
}

/* Header logo sizes — 30% larger than original footer baseline
   Footer uses h-8 (2rem); header variants are 1.3x:
   - sm: 32px * 1.3 = 41.6px  (2.6rem)  — navbar/mobile h-8
   - md: 40px * 1.3 = 52px    (3.25rem) — sidebar h-10
   - lg: 48px * 1.3 = 62.4px  (3.9rem)  — guest poll logo h-12
   - xl: 56px * 1.3 = 72.8px  (4.55rem) — auth page logo h-14
*/
.logo-header-sm  { height: 2.6rem;   width: auto; }
.logo-header-md  { height: 3.25rem;  width: auto; }
.logo-header-lg  { height: 3.9rem;   width: auto; }
.logo-header-xl  { height: 4.55rem;  width: auto; }

/* Sidebar */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    box-shadow: inset 3px 0 0 var(--vp-accent);
}

/* Poll option rows (create/edit form) */
.poll-option-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.poll-option-row .drag-handle {
    cursor: grab;
    color: #9ca3af;
}

.poll-option-row .drag-handle:active {
    cursor: grabbing;
}

/* Card hover effect */
.hover-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.4s ease forwards;
}

@keyframes pulseDot {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--vp-success);
    animation: pulseDot 1.5s ease-in-out infinite;
}

/* Toast notifications */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.875rem 1.25rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    font-size: 0.875rem;
    font-weight: 500;
    color: #ffffff;
    animation: slideIn 0.3s ease forwards;
    max-width: 350px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-success { background-color: var(--vp-success); }
.toast-error { background-color: var(--vp-danger); }
.toast-info { background-color: var(--vp-primary); }

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-hidden {
    display: none;
}

/* Public vote page */
.vote-bg {
    background: linear-gradient(135deg, #1e1b4b 0%, #4c1d95 50%, #6d28d9 100%);
}

/* Progress bars for results */
.result-bar {
    height: 24px;
    border-radius: 0.5rem;
    background: linear-gradient(90deg, var(--vp-primary), var(--vp-primary-dark));
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Token cards */
.token-card {
    background: #faf5ff;
    border: 1px dashed #c4b5fd;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    word-break: break-all;
    cursor: pointer;
    transition: all 0.2s ease;
}

.token-card:hover {
    border-color: var(--vp-primary);
    background: var(--vp-primary-light);
}

.token-card.copied {
    border-color: var(--vp-success);
    background: #ecfdf5;
}

/* Landing page gradient text */
.gradient-text {
    background: linear-gradient(45deg, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Table responsive wrapper */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Print styles */
@media print {
    body {
        background: white;
    }
    .no-print {
        display: none !important;
    }
    .print-area {
        box-shadow: none !important;
        border: none !important;
    }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   Mobile Responsiveness Improvements
   ============================================================ */

/* Toast should fit small screens */
#toast-container {
    right: 0;
    left: 0;
    margin: 0 auto;
    padding: 0 1rem;
    align-items: center;
}

.toast {
    width: calc(100vw - 2rem);
    max-width: 350px;
}

/* User dropdown shouldn't overflow on very narrow screens */
@media (max-width: 380px) {
    #user-dropdown {
        right: 0;
        width: 180px;
    }
}

/* Header: hide site name on very small screens */
@media (max-width: 380px) {
    header .text-lg {
        display: none;
    }
}

/* Ensure main content never underflows the viewport on mobile */
main {
    min-width: 0;
}

/* Prevent grid items (cards) from overflowing their column on mobile */
.grid > * {
    min-width: 0;
    max-width: 100%;
}

/* Dashboard cards: ensure content fits within viewport width */
.bg-white.rounded-xl {
    max-width: 100%;
}

/* Sidebar: consistent width on mobile, slide-in from left */
@media (max-width: 1023px) {
    #sidebar {
        width: 260px;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
}

/* Token manager controls: stack on narrow screens */
@media (max-width: 380px) {
    .token-manager-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .token-manager-controls input,
    .token-manager-controls button {
        width: 100%;
    }
}

/* Poll card action buttons: prevent cramped rows on narrow screens */
@media (max-width: 380px) {
    .flex.gap-2 > a.flex-1,
    .flex.gap-2 > button.flex-1 {
        font-size: 10px;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
}

/* Poll option rows: hide drag handle on small screens to save space */
@media (max-width: 380px) {
    .poll-option-row .drag-handle {
        display: none;
    }
    .poll-option-row input {
        font-size: 13px;
    }
}

/* Results/vote list rows: stack on tiny screens */
@media (max-width: 480px) {
    .flex.items-center.justify-between.text-sm {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* Landing page hero on mobile */
@media (max-width: 640px) {
    section .text-4xl,
    section .text-5xl {
        font-size: 2.25rem;
    }
}