/* 
 * ==========================================
 *  LAYOUT
 *  - Gridstack overrides
 *  - Widget content styling
 *  - Drag handle
 *  - Responsive
 * ==========================================
 */

/* ==========================================
 *  GRIDSTACK OVERRIDES
 * ========================================== */

/* Widget content fills the grid cell */
.grid-stack-item-content {
    border-radius: var(--radius-lg);
    overflow: visible !important;
    inset: 8px !important;
}

/* Inner widget fills the content area */
.gs-widget {
    width: 100%;
    height: 100%;
    overflow: auto;
    border-radius: var(--radius-lg);
    min-width: 250px;
}

/* Drag handle cursor */
.gs-drag-handle {
    cursor: grab;
    user-select: none;
}

.gs-drag-handle:active {
    cursor: grabbing;
}

/* Drag hint icon */
.drag-hint {
    font-size: 0.7rem;
    color: var(--color-text-secondary);
    opacity: 0.4;
    letter-spacing: 2px;
    transition: opacity 0.2s;
    margin-left: 4px;
}

.gs-drag-handle:hover .drag-hint {
    opacity: 0.8;
}

/* Placeholder when dragging */
.grid-stack-placeholder>.placeholder-content {
    border: 2px dashed var(--color-accent) !important;
    border-radius: var(--radius-lg) !important;
    background: rgba(255, 149, 0, 0.05) !important;
}

/* Remove Gridstack default borders */
.grid-stack>.grid-stack-item>.grid-stack-item-content {
    border: none;
    background: none;
}

/* Resize handle styling */
.grid-stack>.grid-stack-item>.ui-resizable-se {
    width: 20px !important;
    height: 20px !important;
    bottom: 4px !important;
    right: 4px !important;
    background: none !important;
}

.grid-stack>.grid-stack-item>.ui-resizable-se::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--color-text-secondary);
    border-bottom: 2px solid var(--color-text-secondary);
    opacity: 0.3;
    transition: opacity 0.2s;
}

.grid-stack>.grid-stack-item:hover>.ui-resizable-se::after {
    opacity: 0.6;
}

/* ==========================================
 *  GENERIC CARD / WIDGET BASE
 * ========================================== */

/* Generic Card / Widget */
.panel,
.hero-card,
.result-card,
.profit-pill,
.history-section,
.japanese-note {
    background: var(--color-surface);
    display: block !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    /* Premium Border Lighting */
    box-shadow:
        var(--shadow-lg),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 5cqi, 2rem);
    transition: var(--transition-base);
    /* No spring on base elements */
    position: relative;
    overflow: hidden;

    /* DEFINIEREN ALS CONTAINER FÜR SKALIERUNG! */
    container-type: inline-size;
    container-name: widget;
}

/* Noise Texture */
.panel::before,
.hero-card::before,
.result-card::before,
.profit-pill::before,
.history-section::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.03;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    z-index: 0;
}

/* Clean grid container without hover bouncing */

/* ==========================================
 *  PANEL & CONTENT TITLES
 * ========================================== */

.panel-title {
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Content Area – for non-grid fallback */
.content-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Exposure Alignment Fix & Absolute Buttons */
.result-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.result-value {
    margin-top: auto;
}

/* Remove old pseudo element */
.result-card::after {
    display: none;
}

/* Profits */
.profit-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Utilities */
.ratio-bar-container {
    display: none !important;
}

/* ==========================================
 *  FLEXBOX LAYOUT (kein GridStack)
 * ========================================== */

.app-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.row-inputs {
    display: flex;
    gap: 16px;
}

.row-results {
    display: flex;
    gap: 16px;
}

.row-results .result-card {
    width: 130px;
    flex-shrink: 0;
    min-height: 80px;
}

.row-profits {
    display: flex;
    gap: 16px;
}

/* Responsive */
@media (max-width: 600px) {
    .stats-widget {
        display: none;
    }
}