/* ===========================================
   DASHBOARD.CSS - Shared Dashboard Components
   For authenticated/dashboard pages only
   =========================================== */

/* ===== TOGGLE BUTTONS ===== */
.btn-toggle-active {
    color: #10B981;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-toggle-active:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
}

.btn-toggle-inactive {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-toggle-inactive:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

/* ===== LINK CARDS ===== */
.links-grid {
    display: grid;
    gap: var(--space-4);
    max-width: 100%;
    overflow: visible;
    padding-top: 4px; /* Space for card hover lift effect */
}

.link-card {
    padding: var(--space-5);
    transition: all var(--transition-base);
    max-width: 100%;
    box-sizing: border-box;
}

.link-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

/* Link Card - Top Row Layout */
.link-top-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.link-title-section {
    flex: 1;
    min-width: 0;
}

.link-title {
    font-size: var(--font-h4-size);
    font-weight: var(--font-h4-weight);
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.link-title i.bi-lock-fill {
    font-size: 1rem;
    flex-shrink: 0;
}

.link-stats-inline {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

.link-stats-inline .stat-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--font-sm-size);
    color: var(--text-secondary);
    white-space: nowrap;
}

.link-stats-inline .stat-item i {
    font-size: 1rem;
    color: var(--text-muted);
}

.link-stats-inline .stat-item strong {
    color: var(--text-primary);
}

.link-status-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

/* Link Card - Bottom Row (URLs) */
.link-urls-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.link-url-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    max-width: 100%;
}

.link-short {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
    font-size: var(--font-body-size);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-short:hover {
    text-decoration: underline;
}

.btn-copy {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

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

.link-original {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-sm-size);
    color: var(--text-secondary);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.link-original i {
    flex-shrink: 0;
}

.original-url-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
    min-width: 0;
    flex: 1;
    text-decoration: none;
    transition: color var(--transition-fast);
}

a.original-url-text:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* ===== EMPTY STATES ===== */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
}

.empty-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-4);
}

.empty-icon i {
    font-size: 2.5rem;
    color: white;
}

.empty-state h3 {
    font-size: var(--font-h3-size);
    font-weight: var(--font-h3-weight);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

.empty-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-muted);
}

.empty-message i {
    font-size: 2rem;
    margin-bottom: var(--space-2);
}

/* ===== LOADING STATES ===== */
.loading-container {
    display: flex;
    justify-content: center;
    padding: var(--space-12);
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border: 4px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
    display: inline-block;
}

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: var(--font-sm-size);
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-4);
    animation: fadeIn 0.2s ease-out;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white !important;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: var(--font-h3-size);
    font-weight: var(--font-h3-weight);
    color: var(--text-primary);
    margin: 0;
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-fast);
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== DESKTOP/MOBILE VISIBILITY ===== */
.desktop-only {
    display: block !important;
}

.mobile-only {
    display: none !important;
}

/* ===== DASHBOARD PAGE HEADER ===== */
.dashboard-page .page-header,
.analytics-page .page-header,
.links-page .page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-8);
}

.dashboard-page .page-title,
.analytics-page .page-title,
.links-page .page-title {
    font-size: var(--font-display-size);
    font-weight: var(--font-display-weight);
    margin-bottom: var(--space-2);
    line-height: var(--font-display-height);
    background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-page .page-subtitle,
.analytics-page .page-subtitle,
.links-page .page-subtitle {
    font-size: var(--font-body-lg);
    color: var(--text-secondary);
    line-height: var(--line-height-relaxed);
}

/* ===== MOBILE LINK CARDS (Analytics table alternative) ===== */
.links-cards {
    flex-direction: column;
    gap: var(--space-3);
}

.link-card-mobile {
    display: block;
    padding: var(--space-4);
    background: linear-gradient(135deg, #FAFBFC 0%, #F4F6F8 100%);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: all var(--transition-fast);
    border: 1px solid var(--border-color);
}

.link-card-mobile:hover,
.link-card-mobile:active {
    background: linear-gradient(135deg, #F0F9FF 0%, #EFF6FF 100%);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.15);
}

.link-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}

.link-card-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.938rem;
    line-height: 1.4;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-card-url {
    font-size: 0.813rem;
    color: var(--text-muted);
    margin-bottom: var(--space-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-bottom: var(--space-3);
    border-bottom: 1px dashed var(--border-color);
}

.link-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--space-2);
}

.link-card-stat {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.link-card-stat i {
    color: var(--color-primary);
    font-size: 1rem;
}

.link-card-clicks {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1rem;
}

.link-card-label {
    color: var(--text-muted);
    font-size: 0.813rem;
}

.link-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.short-code-sm {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    color: var(--color-primary);
    font-weight: 600;
}

.link-card-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== RESPONSIVE - MOBILE ===== */
@media (max-width: 768px) {
    /* Visibility helpers */
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
    }

    /* Link card mobile layout */
    .link-card {
        padding: var(--space-4);
        max-width: 100%;
        overflow: hidden;
    }

    .link-top-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }

    .link-title-section {
        order: 1;
    }

    .link-title {
        font-size: 0.938rem;
        word-break: break-word;
    }

    .link-stats-inline {
        order: 3;
        justify-content: flex-start;
        gap: var(--space-4);
    }

    .link-status-actions {
        order: 2;
        justify-content: space-between;
        width: 100%;
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    .link-urls-row {
        padding-top: var(--space-3);
        overflow: hidden;
    }

    .link-url-group {
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    .link-short {
        font-size: 0.813rem;
        word-break: break-all;
        flex: 1;
        min-width: 0;
    }

    .original-url-text {
        font-size: 0.75rem;
        max-width: 100%;
    }

    .link-original {
        overflow: hidden;
    }

    .badge-group {
        gap: var(--space-2);
        flex-wrap: wrap;
    }

    .action-buttons {
        flex-shrink: 0;
    }

    .action-buttons .btn {
        padding: var(--space-2);
    }

    /* Page header mobile */
    .dashboard-page .page-header,
    .analytics-page .page-header,
    .links-page .page-header {
        flex-direction: column;
        gap: var(--space-4);
        align-items: stretch;
    }

    .dashboard-page .page-header .btn,
    .analytics-page .page-header .btn,
    .links-page .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    .dashboard-page .page-title,
    .analytics-page .page-title,
    .links-page .page-title {
        font-size: var(--font-h2-size);
    }

    /* Empty state mobile */
    .empty-state {
        padding: var(--space-6) var(--space-4);
    }

    .empty-icon {
        width: 64px;
        height: 64px;
    }

    .empty-icon i {
        font-size: 2rem;
    }

    .empty-state h3 {
        font-size: 1.125rem;
    }

    .empty-state p {
        font-size: 0.875rem;
    }

    /* Modal mobile */
    .modal-content {
        margin: var(--space-4);
        max-width: calc(100% - var(--space-8));
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-4);
    }
}

@media (max-width: 480px) {
    .link-card {
        padding: var(--space-3);
    }

    .link-title {
        font-size: 0.875rem;
    }

    .link-stats-inline {
        gap: var(--space-3);
    }

    .link-stats-inline .stat-item {
        font-size: 0.75rem;
    }

    .link-card-mobile {
        padding: var(--space-3);
    }

    .link-card-title {
        font-size: 0.875rem;
    }

    .link-card-url {
        font-size: 0.688rem;
    }

    .link-card-clicks {
        font-size: 0.938rem;
    }

    .short-code-sm {
        font-size: 0.625rem;
        padding: 2px 4px;
    }
}
