/* Base Styles */
html {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    min-height: 100%;
    max-width: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: 100%;
    position: relative;
}

/* Button Styles */
.btn-primary {
    background: linear-gradient(to right, var(--tw-gradient-from), var(--tw-gradient-to));
    --tw-gradient-from: #4F46E5;
    --tw-gradient-to: #0EA5E9;
    transition: all 0.2s ease-in-out;
}

.btn-primary:hover {
    transform: translateY(-1px);
    --tw-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.2);
}

.btn-secondary {
    background: linear-gradient(to right, #0EA5E9, #06B6D4);
}

.btn-danger {
    background: linear-gradient(to right, #EF4444, #DC2626);
}

/* User Profile Dropdown */
#userDropdown {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
                0 4px 6px -2px rgba(0, 0, 0, 0.05);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    background: white;
}

#userDropdown.show {
    opacity: 1;
    transform: translateY(0);
}

#userDropdown a {
    position: relative;
    transition: all 0.2s ease;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
}

#userDropdown a:hover {
    padding-left: 1.5rem;
    background-color: rgba(249, 250, 251, 0.8);
}

#userDropdown a:hover i {
    transform: translateX(2px);
}

#userDropdown i {
    transition: transform 0.2s ease;
    width: 1.5rem;
    text-align: center;
    margin-right: 0.5rem;
}

/* Card Decorations */
.card-decoration {
    position: absolute;
    width: clamp(150px, 30vw, 200px);
    height: clamp(150px, 30vw, 200px);
    background: linear-gradient(to right, var(--tw-gradient-from), var(--tw-gradient-to));
    border-radius: 100%;
    filter: blur(80px);
    z-index: 0;
}

.stat-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease-in-out;
    padding: clamp(1rem, 3vw, 1.5rem);
}

.stat-card:hover {
    transform: translateY(-2px);
}

/* Icon Styles */
.feature-icon {
    background: linear-gradient(to right, var(--tw-gradient-from), var(--tw-gradient-to));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    --tw-gradient-from: #4F46E5;
    --tw-gradient-to: #0EA5E9;
}

/* Table Styles */
.url-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.url-table th {
    background-color: #F9FAFB;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.url-table td {
    vertical-align: middle;
}

.table-cell-truncate {
    max-width: clamp(150px, 30vw, 300px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Animations */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.animate-fade-in {
    animation: fadeIn 0.2s ease-out;
}

/* User Menu Animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slide-down {
    animation: slideDown 0.2s ease-out forwards;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: clamp(250px, 50vh, 300px);
    width: 100%;
}

/* Toast Notifications */
.toast {
    transition: all 0.3s ease-in-out;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    nav .max-w-7xl {
        padding: 0 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .grid {
        gap: 0.75rem;
    }

    .chart-container {
        height: clamp(200px, 40vh, 250px);
    }

    .button-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .button-group > * {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .table-cell-truncate {
        max-width: 120px;
    }
    
    .stat-card {
        padding: 0.75rem;
    }

    #userDropdown {
        position: fixed;
        inset: auto 0 0 0;
        width: 100%;
        max-height: 70vh; /* Reduced from 90vh */
        overflow-y: auto;
        margin: 0;
        border-radius: 1rem 1rem 0 0; /* Reduced border radius */
        transform: translateY(100%);
        box-shadow: 0 -2px 4px -1px rgba(0, 0, 0, 0.1);
        padding-bottom: env(safe-area-inset-bottom);
    }

    #userDropdown.show {
        transform: translateY(0);
    }

    #userDropdown .px-4 {
        padding: 0.75rem; /* Reduced from 1.25rem */
    }

    #userDropdown a {
        padding: 0.75rem; /* Reduced from 1rem */
        font-size: 0.875rem; /* Reduced from 1rem */
        display: flex;
        align-items: center;
        min-height: 2.5rem; /* Reduced from 3rem */
    }

    #userDropdown a i {
        font-size: 1rem; /* Reduced from 1.25rem */
        width: 1.5rem; /* Reduced from 2rem */
        margin-right: 0.75rem; /* Reduced from 1rem */
        text-align: center;
    }

    #userDropdown .border-t {
        margin: 0.25rem 0; /* Reduced from 0.5rem */
    }

    /* Dark overlay when dropdown is open */
    #userDropdown::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
        z-index: -1;
    }

    #userDropdown.show::before {
        opacity: 1;
    }

    /* Mobile handle bar */
    #userDropdown::after {
        content: '';
        position: absolute;
        top: 6px; /* Reduced from 8px */
        left: 50%;
        transform: translateX(-50%);
        width: 32px; /* Reduced from 36px */
        height: 3px; /* Reduced from 4px */
        background: #E5E7EB;
        border-radius: 1.5px;
    }

    .hide-mobile {
        display: none;
    }
}

/* Desktop dropdown styles */
@media (min-width: 641px) {
    #userDropdown {
        position: absolute;
        right: 0;
        top: 100%;
        width: 240px; /* Reduced from 260px */
        margin-top: 0.5rem;
        border-radius: 0.75rem;
    }

    #userDropdown.show {
        transform: translateY(0);
        opacity: 1;
    }

    #userDropdown a {
        padding: 0.625rem 0.875rem; /* Reduced padding */
        font-size: 0.875rem;
        display: flex;
        align-items: center;
        transition: all 0.2s ease;
    }

    #userDropdown a:hover {
        background-color: rgba(249, 250, 251, 0.8);
        padding-left: 1.25rem;
    }

    #userDropdown a i {
        width: 1.25rem; /* Reduced from 1.5rem */
        margin-right: 0.625rem; /* Reduced from 0.75rem */
        transition: transform 0.2s ease;
    }

    #userDropdown a:hover i {
        transform: translateX(2px);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .dark\:bg-gray-900 {
        background-color: #111827;
    }
    
    .dark\:text-white {
        color: #ffffff;
    }

    #userDropdown {
        background-color: #1F2937;
        border-color: rgba(255, 255, 255, 0.1);
    }

    #userDropdown::after {
        background: #4B5563;
    }

    #userDropdown a {
        color: #E5E7EB;
    }

    #userDropdown a:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }
}

/* Loading States */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Error States */
.error-state {
    border-color: #EF4444;
    --tw-ring-color: rgba(239, 68, 68, 0.2);
}

/* Success States */
.success-state {
    border-color: #10B981;
    --tw-ring-color: rgba(16, 185, 129, 0.2);
}

/* Responsive Grid Layout */
.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
}

/* Share Menu Styles */
[id^="share-"] {
    min-width: 200px;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 9999;
}

[id^="share-"].hidden {
    display: none;
}

[id^="share-"] a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #4B5563;
    transition: all 0.2s ease;
    text-decoration: none;
}

[id^="share-"] a:hover {
    background-color: #F3F4F6;
}

[id^="share-"] i {
    width: 1.5rem;
    text-align: center;
    font-size: 1.125rem;
}

/* Message Styles */
.message-safe {
    background-color: #ECFDF5;
    border-left: 4px solid #10B981;
    color: #065F46;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.message-unsafe {
    background-color: #FEF2F2;
    border-left: 4px solid #EF4444;
    color: #991B1B;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.message-warning {
    background-color: #FFFBEB;
    border-left: 4px solid #F59E0B;
    color: #92400E;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}
