/* Tile Component Styles */

/* Base Tile */
.tile {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--neutral-200);
    text-align: center;
    margin: 0 auto;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
}

.tile:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

/* Tile Sizes */
.tile-sm {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
}

.tile-lg {
    padding: var(--space-8);
    border-radius: var(--radius-2xl);
}

.tile-xl {
    padding: var(--space-10);
    border-radius: var(--radius-2xl);
}

/* Tile Types */
.tile-clickable {
    cursor: pointer;
    user-select: none;
}

.tile-clickable:hover {
    border-color: var(--primary-color);
}

.tile-clickable:active {
    transform: translateY(-2px);
}

.tile-featured {
    background: var(--primary-gradient);
    color: var(--text-inverse);
    border-color: var(--primary-color);
}

.tile-featured .tile-title,
.tile-featured .tile-description {
    color: var(--text-inverse);
}

.tile-ghost {
    background: transparent;
    border: 2px dashed var(--neutral-300);
    box-shadow: none;
}

.tile-ghost:hover {
    border-color: var(--primary-color);
    background: var(--neutral-50);
}

/* Tile Header */
.tile-header {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: var(--space-4);
    text-align: center;
}

.tile-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    color: var(--text-inverse);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xl);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-fast);
}

.tile-icon-sm {
    width: 32px;
    height: 32px;
    font-size: var(--text-base);
    border-radius: var(--radius-md);
}

.tile-icon-lg {
    width: 64px;
    height: 64px;
    font-size: var(--text-2xl);
    border-radius: var(--radius-xl);
}

.tile:hover .tile-icon {
    transform: scale(1.1);
}

.tile-badge {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    background: var(--error-color);
    color: var(--text-inverse);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

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

.tile-badge-warning {
    background: var(--warning-color);
}

.tile-badge-info {
    background: var(--info-color);
}

/* Tile Content */
.tile-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    line-height: 1.3;
    text-align: center;
}

.tile-title-sm {
    font-size: var(--text-lg);
}

.tile-title-lg {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-3);
}

.tile-description {
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--space-4);
    text-align: center;
}

.tile-description-sm {
    font-size: var(--text-sm);
}

.tile-meta {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    margin-bottom: var(--space-4);
}

.tile-meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.tile-meta-item i {
    font-size: var(--text-xs);
}

/* Tile Actions */
.tile-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: auto !important;
    padding-top: var(--space-4);
    justify-content: center;
    align-items: center;
}

.tile-action {
    background: none;
    border: 1px solid var(--neutral-300);
    color: var(--text-secondary);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tile-action:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.tile-action-primary {
    background: var(--primary-color);
    color: var(--text-inverse);
    border-color: var(--primary-color);
}

.tile-action-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Tile Footer */
.tile-footer {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--neutral-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

/* Tile Status */
.tile-status {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--success-color);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.tile-status-warning {
    background: var(--warning-color);
}

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

.tile-status-info {
    background: var(--info-color);
}

/* Tile Progress */
.tile-progress {
    margin-top: var(--space-3);
}

.tile-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--neutral-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.tile-progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: var(--radius-full);
    transition: width var(--transition-base);
}

.tile-progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

/* Tile Grid Layouts */
.tile-grid {
    display: grid !important;
    gap: var(--space-6);
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    justify-content: center !important;
    justify-items: stretch !important;
    align-items: stretch !important;
    grid-auto-rows: 1fr !important;
}

.tile-grid-sm {
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    justify-content: center !important;
    justify-items: stretch !important;
    align-items: stretch !important;
    grid-auto-rows: 1fr !important;
}

.tile-grid-lg {
    gap: var(--space-8);
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)) !important;
    justify-content: center !important;
    justify-items: stretch !important;
    align-items: stretch !important;
    grid-auto-rows: 1fr !important;
}

.tile-grid-fixed-2 {
    grid-template-columns: repeat(2, 1fr) !important;
    justify-content: center !important;
    justify-items: stretch !important;
    align-items: stretch !important;
    grid-auto-rows: 1fr !important;
}

.tile-grid-fixed-3 {
    grid-template-columns: repeat(3, 1fr) !important;
    justify-content: center !important;
    justify-items: stretch !important;
    align-items: stretch !important;
    grid-auto-rows: 1fr !important;
}

.tile-grid-fixed-4 {
    grid-template-columns: repeat(4, 1fr) !important;
    justify-content: center !important;
    justify-items: stretch !important;
    align-items: stretch !important;
    grid-auto-rows: 1fr !important;
}

/* Tile Spans */
.tile-span-2 {
    grid-column: span 2;
}

.tile-span-3 {
    grid-column: span 3;
}

.tile-row-span-2 {
    grid-row: span 2;
}

/* Tile Animations */
.tile-fade-in {
    opacity: 0;
    transform: translateY(20px);
    animation: tileSlideIn 0.5s ease-out forwards;
}

@keyframes tileSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tile-scale-in {
    opacity: 0;
    transform: scale(0.9);
    animation: tileScaleIn 0.4s ease-out forwards;
}

@keyframes tileScaleIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Interactive States */
.tile-loading {
    position: relative;
    pointer-events: none;
}

.tile-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    border-radius: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.tile-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--neutral-300);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: tileLoadingSpin 1s linear infinite;
}

@keyframes tileLoadingSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 479px) {
    .tile-grid {
        display: grid;
        gap: var(--space-4);
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        justify-content: center;
        justify-items: stretch;
        align-items: stretch;
        grid-auto-rows: 1fr;
    }
    
    .tile-grid-sm {
        gap: var(--space-3);
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        justify-content: center;
        justify-items: stretch;
        align-items: stretch;
        grid-auto-rows: 1fr;
    }
    
    .tile-grid-fixed-2,
    .tile-grid-fixed-3,
    .tile-grid-fixed-4 {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        justify-content: center;
        justify-items: stretch;
        align-items: stretch;
        grid-auto-rows: 1fr;
    }
    
    .tile {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
        text-align: center;
    }
    
    .tile-span-2,
    .tile-span-3 {
        grid-column: span 1;
    }
    
    .tile-actions {
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    
    .tile-header {
        justify-content: center;
        text-align: center;
    }
    
    .tile-title,
    .tile-description {
        text-align: center;
    }
}

/* Portrait-specific adjustments for small mobile tiles */
@media (max-width: 479px) and (orientation: portrait) {
    .tile-grid {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: clamp(var(--space-2), 3vw, var(--space-4));
        justify-content: space-evenly !important;
        align-items: stretch !important;
        width: 100%;
        padding: 0 var(--space-2);
    }
    
    .tile-grid-sm {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: clamp(var(--space-1), 2vw, var(--space-3));
        justify-content: space-evenly !important;
        align-items: stretch !important;
    }
    
    .tile-grid-fixed-2,
    .tile-grid-fixed-3,
    .tile-grid-fixed-4 {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: clamp(var(--space-2), 3vw, var(--space-4));
        justify-content: space-evenly !important;
        align-items: stretch !important;
    }
    
    .tile {
        flex: 1 !important;
        min-width: 0 !important;
        max-width: none !important;
        width: auto !important;
        margin: 0 !important;
        text-align: center !important;
        padding: clamp(var(--space-2), 4vw, var(--space-4));
        transform: scale(0.95);
        height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }
    
    .tile-header {
        justify-content: center !important;
        text-align: center !important;
        margin-bottom: clamp(var(--space-1), 2vw, var(--space-2));
    }
    
    .tile-icon {
        width: clamp(24px, 8vw, 40px) !important;
        height: clamp(24px, 8vw, 40px) !important;
        margin: 0 auto clamp(var(--space-1), 2vw, var(--space-2)) auto !important;
        font-size: clamp(0.75rem, 4vw, 1rem) !important;
    }
    
    .tile-title {
        font-size: clamp(0.7rem, 3.5vw, 0.9rem) !important;
        text-align: center !important;
        margin-bottom: clamp(var(--space-1), 1.5vw, var(--space-2)) !important;
        line-height: 1.2 !important;
    }
    
    .tile-description {
        font-size: clamp(0.6rem, 3vw, 0.75rem) !important;
        text-align: center !important;
        line-height: 1.3 !important;
        margin-bottom: clamp(var(--space-1), 2vw, var(--space-2)) !important;
    }
    
    .tile-actions {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: clamp(var(--space-1), 2vw, var(--space-2)) !important;
        margin-top: auto !important;
    }
    
    .tile-action {
        padding: clamp(var(--space-1), 2vw, var(--space-2)) clamp(var(--space-2), 3vw, var(--space-3)) !important;
        font-size: clamp(0.6rem, 2.5vw, 0.75rem) !important;
        width: 100% !important;
        text-align: center !important;
    }
}

@media (min-width: 480px) and (max-width: 640px) {
    .tile-grid,
    .tile-grid-fixed-2,
    .tile-grid-fixed-3,
    .tile-grid-fixed-4 {
        grid-template-columns: 1fr;
        justify-content: center;
        justify-items: stretch;
        align-items: stretch;
        grid-auto-rows: 1fr;
    }
    
    .tile {
        text-align: center;
        margin: 0 auto;
        width: 100%;
    }
    
    .tile-header {
        justify-content: center;
        text-align: center;
    }
    
    .tile-title,
    .tile-description {
        text-align: center;
    }
    
    .tile-span-2,
    .tile-span-3 {
        grid-column: span 1;
    }
    
    .tile-actions {
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
}

@media (min-width: 641px) and (max-width: 1023px) {
    .tile-grid,
    .tile-grid-fixed-3,
    .tile-grid-fixed-4 {
        grid-template-columns: repeat(2, 1fr);
        justify-content: center;
        justify-items: stretch;
        align-items: stretch;
        grid-auto-rows: 1fr;
    }
    
    .tile-grid-fixed-2 {
        grid-template-columns: repeat(2, 1fr);
        justify-content: center;
        justify-items: stretch;
        align-items: stretch;
        grid-auto-rows: 1fr;
    }
    
    .tile {
        text-align: center;
        margin: 0 auto;
        width: 100%;
    }
    
    .tile-header {
        justify-content: center;
        text-align: center;
    }
    
    .tile-title,
    .tile-description {
        text-align: center;
    }
    
    .tile-actions {
        align-items: center;
        justify-content: center;
    }
    
    .tile-span-2 {
        grid-column: span 2;
    }
    
    .tile-span-3 {
        grid-column: span 2;
    }
}

@media (min-width: 768px) {
    .md\:tile-grid-2 {
        grid-template-columns: repeat(2, 1fr);
        justify-content: center;
        justify-items: stretch;
        align-items: stretch;
        grid-auto-rows: 1fr;
    }
    
    .md\:tile-grid-3 {
        grid-template-columns: repeat(3, 1fr);
        justify-content: center;
        justify-items: stretch;
        align-items: stretch;
        grid-auto-rows: 1fr;
    }
    
    .tile {
        text-align: center;
        margin: 0 auto;
        width: 100%;
    }
    
    .tile-header {
        justify-content: center;
        text-align: center;
    }
    
    .tile-title,
    .tile-description {
        text-align: center;
    }
    
    .tile-actions {
        align-items: center;
        justify-content: center;
    }
}

@media (min-width: 1024px) {
    .lg\:tile-grid-3 {
        grid-template-columns: repeat(3, 1fr);
        justify-content: center;
        justify-items: stretch;
        align-items: stretch;
        grid-auto-rows: 1fr;
    }
    
    .lg\:tile-grid-4 {
        grid-template-columns: repeat(4, 1fr);
        justify-content: center;
        justify-items: stretch;
        align-items: stretch;
        grid-auto-rows: 1fr;
    }
    
    .tile {
        text-align: center;
        margin: 0 auto;
        width: 100%;
    }
    
    .tile-header {
        justify-content: center;
        text-align: center;
    }
    
    .tile-title,
    .tile-description {
        text-align: center;
    }
    
    .tile-actions {
        align-items: center;
        justify-content: center;
    }
}

/* FORCE LEVEL TILES - Override any conflicting styles */
.tile-grid,
.tile-grid-sm,
.tile-grid-lg,
.tile-grid-fixed-2,
.tile-grid-fixed-3,
.tile-grid-fixed-4 {
    align-items: stretch !important;
    grid-auto-rows: 1fr !important;
}

.tile-grid .tile,
.tile-grid-sm .tile,
.tile-grid-lg .tile,
.tile-grid-fixed-2 .tile,
.tile-grid-fixed-3 .tile,
.tile-grid-fixed-4 .tile {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
}

/* Ensure consistent tile structure for leveling */
.tile .tile-actions {
    margin-top: auto !important;
}

.tile .tile-header,
.tile .tile-title,
.tile .tile-description {
    flex-shrink: 0 !important;
} 