/*
 * Croplod Components
 * Google Account quality, dark theme support
 */

/* === Container === */
.container {
    width: 100%;
    max-width: var(--container-lg, 1200px);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.625rem 1.25rem;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background-color var(--transition-fast),
                box-shadow var(--transition-fast),
                transform var(--transition-fast);
    white-space: nowrap;
    line-height: 1;
    font-family: var(--font-family);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    min-height: var(--touch-target);
}

.btn:active {
    transform: scale(0.98);
}

.btn:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-600));
    color: white;
    box-shadow: 0 2px 8px var(--btn-primary-shadow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-primary-600), var(--color-primary-700));
    box-shadow: 0 4px 12px var(--btn-primary-shadow-hover);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-secondary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

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

.btn-danger {
    background: linear-gradient(135deg, var(--color-error-500), var(--color-error-600));
    color: white;
    box-shadow: 0 2px 8px var(--btn-danger-shadow);
}

.btn-danger:hover {
    box-shadow: 0 4px 12px var(--btn-danger-shadow-hover);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--font-size-xs);
    min-height: 36px;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: var(--font-size-base);
}

.btn-block {
    width: 100%;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* === Badge === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary {
    background-color: rgba(99, 102, 241, 0.12);
    color: var(--color-primary-600);
}

.badge-success {
    background-color: rgba(34, 197, 94, 0.12);
    color: var(--color-success-600);
}

.badge-error {
    background-color: rgba(239, 68, 68, 0.12);
    color: var(--color-error-600);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.12);
    color: var(--color-warning-600);
}

[data-theme="dark"] .badge-primary {
    background-color: rgba(129, 140, 248, 0.16);
    color: var(--color-primary-300);
}

[data-theme="dark"] .badge-success {
    background-color: rgba(34, 197, 94, 0.16);
    color: var(--color-success-500);
}

[data-theme="dark"] .badge-error {
    background-color: rgba(239, 68, 68, 0.16);
    color: var(--color-error-500);
}

[data-theme="dark"] .badge-warning {
    background-color: rgba(245, 158, 11, 0.16);
    color: var(--color-warning-500);
}

/* === Avatar === */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-400));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-semibold);
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: var(--font-size-xl);
}

.avatar-xl {
    width: 96px;
    height: 96px;
    font-size: var(--font-size-2xl);
}

/* === Divider === */
.divider {
    height: 1px;
    background-color: var(--border-subtle);
    border: none;
    margin: var(--space-lg) 0;
}

/* === Toast === */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 16px);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow-elevated);
    pointer-events: auto;
    animation: toast-in 0.3s ease;
    min-width: 280px;
    max-width: calc(100vw - 32px);
    font-size: 14px;
}

.toast-success {
    border-right: 3px solid var(--color-success-500);
}

.toast-error {
    border-right: 3px solid var(--color-error-500);
}

.toast-info {
    border-right: 3px solid var(--color-primary-500);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

/* === Theme Toggle === */
.theme-toggle {
    position: relative;
    width: 48px;
    height: 28px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    flex-shrink: 0;
}

.theme-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    background-color: var(--color-primary-500);
    border-radius: var(--radius-full);
    transition: transform var(--transition-fast);
}

[data-theme="dark"] .theme-toggle::after {
    transform: translateX(-20px);
}

.theme-toggle-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.theme-toggle-icon--light {
    right: 6px;
    opacity: 1;
}

.theme-toggle-icon--dark {
    left: 6px;
    opacity: 0;
}

[data-theme="dark"] .theme-toggle-icon--light { opacity: 0; }
[data-theme="dark"] .theme-toggle-icon--dark { opacity: 1; }

/* === Spinner === */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--color-primary-500);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

/* === List Item === */
.list-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    transition: background-color var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    min-height: var(--touch-target);
}

.list-item:hover {
    background-color: var(--bg-hover);
}

.list-item:active {
    background-color: var(--bg-pressed);
}

.list-item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background-color: var(--icon-bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary-500);
    flex-shrink: 0;
}

[data-theme="dark"] .list-item-icon {
    background-color: var(--icon-bg-primary);
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    overflow-wrap: break-word;
    word-break: break-word;
}

.list-item-desc {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-top: 2px;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* === SVG Icon === */
.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.icon-lg {
    width: 24px;
    height: 24px;
}

/* === Stat Card === */
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    transition: box-shadow 200ms ease, background-color 200ms ease;
}

.stat-card:hover {
    box-shadow: var(--card-shadow-hover);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card-icon svg {
    width: 22px;
    height: 22px;
}

.stat-card-icon--blue {
    background-color: var(--icon-bg-blue);
    color: var(--sidebar-color-home);
}

.stat-card-icon--green {
    background-color: var(--icon-bg-green);
    color: var(--sidebar-color-account);
}

.stat-card-icon--orange {
    background-color: var(--icon-bg-orange);
    color: var(--sidebar-color-security);
}

.stat-card-icon--purple {
    background-color: var(--icon-bg-purple);
    color: var(--sidebar-color-notifications);
}

.stat-card-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-card-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

/* === Info Row === */
.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-subtle);
    gap: 12px;
}

.info-row:last-child {
    border-bottom: none;
}

.info-row-label {
    font-size: 14px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.info-row-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-all;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-desc {
    font-size: 14px;
    color: var(--text-secondary);
}

/* === Table Responsive === */
@media (max-width: 639px) {
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-lg);
    }

    .table-responsive table {
        min-width: 480px;
    }

    .toast {
        min-width: auto;
        max-width: calc(100vw - 32px);
    }
}
