/**
 * Dividendenkalender WordPress Plugin Styles
 *
 * Using BEM naming convention with dk- prefix
 *
 * @package Dividendenkalender
 * @since 1.0.0
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */

:root {
    /* Gray scale */
    --dk-gray-50: #f9fafb;
    --dk-gray-100: #f3f4f6;
    --dk-gray-200: #e5e7eb;
    --dk-gray-300: #d1d5db;
    --dk-gray-400: #9ca3af;
    --dk-gray-500: #6b7280;
    --dk-gray-600: #4b5563;
    --dk-gray-700: #374151;
    --dk-gray-800: #1f2937;
    --dk-gray-900: #111827;

    /* Primary colors */
    --dk-primary: #2563eb;
    --dk-primary-light: #dbeafe;
    --dk-primary-dark: #1d4ed8;

    /* Semantic colors */
    --dk-success: #16a34a;
    --dk-success-light: #dcfce7;
    --dk-warning: #d97706;
    --dk-warning-light: #fef3c7;
    --dk-danger: #dc2626;
    --dk-danger-light: #fee2e2;
    --dk-info: #0891b2;
    --dk-info-light: #cffafe;

    /* Borders and shadows */
    --dk-border-radius: 0.5rem;
    --dk-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --dk-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

.dk-index-container,
.dk-stock-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--dk-gray-800);
    max-width: 100%;
    margin: 0 auto;
}

/* ==========================================================================
   Index Container
   ========================================================================== */

.dk-index-header {
    margin-bottom: 1.5rem;
}

.dk-index-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dk-gray-900);
    margin: 0 0 0.5rem 0;
}

.dk-index-subtitle {
    font-size: 1rem;
    color: var(--dk-gray-600);
    margin: 0;
}

.dk-index-footer,
.dk-stock-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--dk-gray-200);
}

.dk-source {
    font-size: 0.75rem;
    color: var(--dk-gray-500);
    margin: 0;
}

.dk-source a {
    color: var(--dk-primary);
    text-decoration: none;
}

.dk-source a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Table Styles
   ========================================================================== */

.dk-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.dk-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background: white;
    border-radius: var(--dk-border-radius);
    box-shadow: var(--dk-shadow);
}

.dk-table__th {
    background: var(--dk-gray-50);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dk-gray-600);
    border-bottom: 2px solid var(--dk-gray-200);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.dk-table__th[data-sortable="false"] {
    cursor: default;
}

.dk-table__th[data-sortable="true"]:hover {
    background: var(--dk-gray-100);
}

.dk-table__th[data-sortable="true"]:hover .dk-sort-icon {
    opacity: 0.6;
}

.dk-table__th--rank,
.dk-table__th--logo {
    width: 50px;
    text-align: center;
}

.dk-table__th--dividend,
.dk-table__th--yield,
.dk-table__th--divi_score,
.dk-table__th--cagr_3y,
.dk-table__th--cagr_5y,
.dk-table__th--cagr_10y,
.dk-table__th--price,
.dk-table__th--change {
    text-align: right;
}

.dk-sort-icon {
    display: inline-block;
    margin-left: 0.25rem;
    opacity: 0.3;
    font-size: 0.625rem;
}

.dk-sort-icon::after {
    content: '\25B2\25BC';
    letter-spacing: -0.25em;
}

.dk-table__th--sorted-asc .dk-sort-icon {
    opacity: 1;
}

.dk-table__th--sorted-asc .dk-sort-icon::after {
    content: '\25B2';
}

.dk-table__th--sorted-desc .dk-sort-icon {
    opacity: 1;
}

.dk-table__th--sorted-desc .dk-sort-icon::after {
    content: '\25BC';
}

.dk-table__row {
    transition: background-color 0.15s ease;
}

.dk-table__row:hover {
    background: var(--dk-gray-50);
}

.dk-table__row:nth-child(even) {
    background: var(--dk-gray-50);
}

.dk-table__row:nth-child(even):hover {
    background: var(--dk-gray-100);
}

.dk-table__cell {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--dk-gray-200);
    vertical-align: middle;
}

.dk-table__cell--rank,
.dk-table__cell--logo {
    text-align: center;
}

.dk-table__cell--dividend,
.dk-table__cell--yield,
.dk-table__cell--divi_score,
.dk-table__cell--cagr_3y,
.dk-table__cell--cagr_5y,
.dk-table__cell--cagr_10y,
.dk-table__cell--price,
.dk-table__cell--change {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Cell Content Styles
   ========================================================================== */

.dk-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--dk-gray-100);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dk-gray-600);
}

.dk-company-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
}

.dk-no-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--dk-gray-200);
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--dk-gray-500);
    text-transform: uppercase;
}

.dk-company-name {
    font-weight: 500;
    color: var(--dk-gray-900);
}

.dk-date {
    font-variant-numeric: tabular-nums;
}

.dk-date--past {
    color: var(--dk-gray-400);
}

.dk-date--future {
    color: var(--dk-gray-900);
    font-weight: 500;
}

.dk-na {
    color: var(--dk-gray-400);
    font-style: italic;
}

.dk-dividend {
    font-weight: 500;
}

.dk-yield {
    font-weight: 500;
}

.dk-yield--high {
    color: var(--dk-success);
}

.dk-yield--medium {
    color: var(--dk-warning);
}

.dk-yield--low {
    color: var(--dk-gray-600);
}

.dk-diviscore {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.875rem;
}

.dk-diviscore--excellent {
    background: var(--dk-success-light);
    color: var(--dk-success);
}

.dk-diviscore--good {
    background: var(--dk-info-light);
    color: var(--dk-info);
}

.dk-diviscore--average {
    background: var(--dk-warning-light);
    color: var(--dk-warning);
}

.dk-diviscore--poor {
    background: var(--dk-danger-light);
    color: var(--dk-danger);
}

.dk-cagr {
    font-weight: 500;
}

.dk-cagr--positive {
    color: var(--dk-success);
}

.dk-cagr--negative {
    color: var(--dk-danger);
}

.dk-price {
    font-weight: 500;
    color: var(--dk-gray-900);
}

.dk-change {
    font-weight: 500;
}

.dk-change--positive {
    color: var(--dk-success);
}

.dk-change--negative {
    color: var(--dk-danger);
}

.dk-change--neutral {
    color: var(--dk-gray-500);
}

/* ==========================================================================
   Stock Detail Styles
   ========================================================================== */

.dk-stock-container {
    max-width: 1200px;
}

.dk-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dk-gray-900);
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--dk-gray-200);
}

/* Hero Section */
.dk-stock-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1.5rem;
    background: white;
    border-radius: var(--dk-border-radius);
    box-shadow: var(--dk-shadow);
    margin-bottom: 2rem;
}

.dk-stock-hero__header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dk-stock-hero__logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 8px;
    background: var(--dk-gray-50);
    padding: 8px;
}

.dk-stock-hero__name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dk-gray-900);
    margin: 0 0 0.25rem 0;
}

.dk-stock-hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--dk-gray-500);
}

.dk-stock-hero__symbol {
    font-weight: 600;
    color: var(--dk-gray-700);
}

.dk-stock-hero__price {
    text-align: right;
}

.dk-stock-hero__price-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--dk-gray-900);
}

.dk-stock-hero__price-change {
    font-size: 1rem;
    font-weight: 500;
}

/* Metrics Section */
.dk-stock-metrics {
    margin-bottom: 2rem;
}

.dk-metrics-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.dk-metric-card {
    padding: 1.25rem;
    background: white;
    border-radius: var(--dk-border-radius);
    box-shadow: var(--dk-shadow-sm);
    border-left: 4px solid var(--dk-gray-200);
}

.dk-metric-card--positive {
    border-left-color: var(--dk-success);
}

.dk-metric-card--negative {
    border-left-color: var(--dk-danger);
}

.dk-metric-card--high,
.dk-metric-card--excellent {
    border-left-color: var(--dk-success);
}

.dk-metric-card--medium,
.dk-metric-card--good {
    border-left-color: var(--dk-info);
}

.dk-metric-card--average {
    border-left-color: var(--dk-warning);
}

.dk-metric-card--poor {
    border-left-color: var(--dk-danger);
}

.dk-metric-card__label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dk-gray-500);
    margin-bottom: 0.5rem;
}

.dk-metric-card__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dk-gray-900);
    margin-bottom: 0.25rem;
}

.dk-metric-card__rating {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--dk-gray-600);
    margin-top: 0.25rem;
}

.dk-metric-card__desc {
    font-size: 0.75rem;
    color: var(--dk-gray-500);
    line-height: 1.4;
}

/* Dates Section */
.dk-stock-dates {
    margin-bottom: 2rem;
}

.dk-dates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.dk-date-card {
    padding: 1.25rem;
    background: white;
    border-radius: var(--dk-border-radius);
    box-shadow: var(--dk-shadow-sm);
    text-align: center;
}

.dk-date-card__label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dk-gray-500);
    margin-bottom: 0.5rem;
}

.dk-date-card__value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dk-gray-900);
    margin-bottom: 0.25rem;
}

.dk-date-card__desc {
    font-size: 0.75rem;
    color: var(--dk-gray-500);
    line-height: 1.4;
}

/* Chart Section */
.dk-stock-chart {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: var(--dk-border-radius);
    box-shadow: var(--dk-shadow);
}

.dk-chart-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dk-chart-period {
    padding: 0.5rem 1rem;
    background: var(--dk-gray-100);
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--dk-gray-600);
    cursor: pointer;
    transition: all 0.15s ease;
}

.dk-chart-period:hover {
    background: var(--dk-gray-200);
}

.dk-chart-period--active {
    background: var(--dk-primary);
    color: white;
}

.dk-chart-period--active:hover {
    background: var(--dk-primary-hover);
}

.dk-chart-container {
    position: relative;
    height: 300px;
}

.dk-chart-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--dk-gray-500);
}

/* History Section */
.dk-stock-history {
    margin-bottom: 2rem;
}

.dk-table--history .dk-table__th {
    background: var(--dk-gray-100);
}

.dk-no-data {
    padding: 2rem;
    text-align: center;
    color: var(--dk-gray-500);
    background: var(--dk-gray-50);
    border-radius: var(--dk-border-radius);
}

/* ==========================================================================
   Error State
   ========================================================================== */

.dk-error {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--dk-danger-light);
    border: 1px solid var(--dk-danger);
    border-radius: var(--dk-border-radius);
    color: var(--dk-danger);
}

.dk-error__icon {
    font-size: 1.25rem;
}

.dk-error__message {
    font-weight: 500;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media (max-width: 1024px) {
    .dk-metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .dk-index-title {
        font-size: 1.5rem;
    }

    .dk-table__th,
    .dk-table__cell {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    .dk-stock-hero {
        flex-direction: column;
        gap: 1rem;
    }

    .dk-stock-hero__price {
        text-align: left;
    }

    .dk-stock-hero__price-value {
        font-size: 1.5rem;
    }

    .dk-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dk-dates-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .dk-metric-card__value {
        font-size: 1.25rem;
    }

    .dk-chart-container {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .dk-metrics-grid {
        grid-template-columns: 1fr;
    }

    .dk-dates-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .dk-table {
        font-size: 0.75rem;
    }

    .dk-table__th,
    .dk-table__cell {
        padding: 0.5rem;
    }

    .dk-chart-period {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .dk-index-container,
    .dk-stock-container {
        box-shadow: none;
    }

    .dk-chart-controls,
    .dk-chart-container {
        display: none;
    }

    .dk-table {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .dk-table__row:hover {
        background: transparent;
    }
}
