/**
 * Polifilm Table of Contents - Styles
 * Version: 1.1.0
 */

:root {
    --ptoc-primary: #f97316;
    --ptoc-width: 260px;
    --ptoc-bg: #ffffff;
    --ptoc-text: #000000;
    --ptoc-text-muted: #333333;
    --ptoc-border: #e5e5e5;
    --ptoc-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    --ptoc-radius: 16px;
    --ptoc-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Yatay scroll'u engelle */
html, body {
    overflow-x: hidden;
}

/* ==================== WRAPPER ==================== */
.ptoc-wrapper {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: var(--ptoc-width);
    max-height: calc(100vh - 200px);
    z-index: 999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.ptoc-left {
    left: 24px;
}

.ptoc-right {
    right: 24px;
}

.ptoc-inner {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--ptoc-radius);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* ==================== HEADER ==================== */
.ptoc-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 16px;
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
}

.ptoc-title {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #f97316;
    transition: color 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    text-align: center;
}

.ptoc-wrapper.has-active .ptoc-title {
    color: #1a1a1a;
}

.ptoc-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.04);
    border: none;
    color: #999;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ptoc-transition);
    flex-shrink: 0;
}

.ptoc-toggle:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #666;
}

.ptoc-toggle svg {
    transition: transform 0.3s ease;
}

.ptoc-wrapper.collapsed .ptoc-toggle svg {
    transform: rotate(180deg);
}

.ptoc-wrapper.collapsed .ptoc-list {
    display: none;
}

/* ==================== LIST ==================== */
.ptoc-list {
    max-height: calc(70vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(249, 115, 22, 0.5) transparent;
    padding: 8px 0;
    background: transparent;
}

.ptoc-list::-webkit-scrollbar {
    width: 3px;
}

.ptoc-list::-webkit-scrollbar-track {
    background: transparent;
}

.ptoc-list::-webkit-scrollbar-thumb {
    background: rgba(249, 115, 22, 0.5);
    border-radius: 3px;
}

.ptoc-list::-webkit-scrollbar-thumb:hover {
    background: #f97316;
}

.ptoc-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ptoc-list li {
    margin: 0;
    padding: 0;
}

.ptoc-list a {
    display: block;
    padding: 11px 18px;
    color: #222;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.5;
    transition: var(--ptoc-transition);
    border-left: 3px solid transparent;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: transparent;
}

.ptoc-list a:hover {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
    padding-left: 20px;
}

.ptoc-list li.active a {
    background: rgba(249, 115, 22, 0.12);
    color: #ea580c;
    font-weight: 600;
    border-left-color: #f97316;
}

/* Heading Levels */
.ptoc-level-2 a { padding-left: 18px; }
.ptoc-level-3 a { padding-left: 30px; font-size: 12px; }
.ptoc-level-4 a { padding-left: 42px; font-size: 12px; color: #444; }
.ptoc-level-5 a { padding-left: 54px; font-size: 11px; color: #555; }
.ptoc-level-6 a { padding-left: 66px; font-size: 11px; color: #555; }

/* Hover states for levels */
.ptoc-level-3 a:hover { padding-left: 32px; }
.ptoc-level-4 a:hover { padding-left: 44px; }

/* ==================== PROGRESS ==================== */
.ptoc-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(0, 0, 0, 0.05);
}

.ptoc-progress-bar {
    height: 100%;
    width: 0%;
    background: #f97316;
    transition: width 0.1s ease;
}

/* ==================== STYLE: MINIMAL ==================== */
.ptoc-style-minimal .ptoc-inner {
    background: transparent;
    box-shadow: none;
    border: none;
}

.ptoc-style-minimal .ptoc-header {
    background: transparent;
    color: var(--ptoc-text);
    padding: 0 0 12px 0;
    border-bottom: 2px solid #f97316;
}

.ptoc-style-minimal .ptoc-toggle {
    background: var(--ptoc-border);
    color: var(--ptoc-text);
}

.ptoc-style-minimal .ptoc-list {
    background: transparent;
}

.ptoc-style-minimal .ptoc-list a {
    padding: 8px 0 8px 12px;
    border-left: 2px solid var(--ptoc-border);
}

.ptoc-style-minimal .ptoc-list li.active a {
    background: transparent;
    border-left-color: #f97316;
}

.ptoc-style-minimal .ptoc-progress {
    display: none;
}

/* ==================== STYLE: LINE ==================== */
.ptoc-style-line .ptoc-inner {
    background: transparent;
    box-shadow: none;
    border: none;
}

.ptoc-style-line .ptoc-header {
    background: transparent;
    color: var(--ptoc-text);
    padding: 0 0 16px 0;
}

.ptoc-style-line .ptoc-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ptoc-text-muted);
}

.ptoc-style-line .ptoc-list {
    position: relative;
}

.ptoc-style-line .ptoc-list::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--ptoc-border);
    border-radius: 2px;
}

.ptoc-style-line .ptoc-list a {
    padding: 8px 8px 8px 24px;
    border-left: none;
    position: relative;
}

.ptoc-style-line .ptoc-list a::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ptoc-bg);
    border: 2px solid var(--ptoc-border);
    transition: var(--ptoc-transition);
}

.ptoc-style-line .ptoc-list li.active a::before {
    background: #f97316;
    border-color: #f97316;
    box-shadow: 0 0 0 4px color-mix(in srgb, #f97316, transparent 70%);
}

.ptoc-style-line .ptoc-progress {
    display: none;
}

/* ==================== STYLE: DOTS ==================== */
.ptoc-style-dots .ptoc-wrapper {
    width: auto;
}

.ptoc-style-dots .ptoc-inner {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px 8px;
}

.ptoc-style-dots .ptoc-header {
    display: none;
}

.ptoc-style-dots .ptoc-list ul {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
}

.ptoc-style-dots .ptoc-list a {
    width: 12px;
    height: 12px;
    padding: 0;
    border-radius: 50%;
    background: var(--ptoc-border);
    border: none;
    font-size: 0;
    transition: var(--ptoc-transition);
    position: relative;
}

.ptoc-style-dots .ptoc-list a:hover {
    background: color-mix(in srgb, #f97316, transparent 50%);
    transform: scale(1.2);
}

.ptoc-style-dots .ptoc-list li.active a {
    background: #f97316;
    transform: scale(1.3);
    box-shadow: 0 0 0 4px color-mix(in srgb, #f97316, transparent 70%);
}

/* Dots tooltip */
.ptoc-style-dots .ptoc-list a::after {
    content: attr(data-title);
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--ptoc-text);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--ptoc-transition);
    pointer-events: none;
}

.ptoc-style-dots.ptoc-left .ptoc-list a::after {
    right: auto;
    left: calc(100% + 12px);
}

.ptoc-style-dots .ptoc-list a:hover::after {
    opacity: 1;
    visibility: visible;
}

.ptoc-style-dots .ptoc-progress {
    display: none;
}

/* ==================== STYLE: CARD ==================== */
.ptoc-style-card .ptoc-inner {
    background: linear-gradient(180deg, var(--ptoc-bg) 0%, #f9fafb 100%);
}

.ptoc-style-card .ptoc-list a {
    margin: 4px 8px;
    border-radius: 8px;
    border-left: none;
}

.ptoc-style-card .ptoc-list a:hover {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.ptoc-style-card .ptoc-list li.active a {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left: none;
}

.ptoc-style-card .ptoc-list li.active a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: #f97316;
    border-radius: 0 3px 3px 0;
}

/* ==================== MOBILE FAB ==================== */
.ptoc-fab {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #f97316;
    color: #fff;
    border: none;
    box-shadow: var(--ptoc-shadow-lg);
    cursor: pointer;
    z-index: 998;
    align-items: center;
    justify-content: center;
    transition: var(--ptoc-transition);
}

.ptoc-fab:hover {
    transform: scale(1.1);
    background: #ea580c;
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.2);
}

.ptoc-fab:active {
    transform: scale(0.95);
}

/* ==================== MOBILE DRAWER ==================== */
.ptoc-mobile-drawer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.ptoc-mobile-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ptoc-mobile-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: var(--ptoc-bg);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.ptoc-mobile-drawer.active .ptoc-mobile-overlay {
    opacity: 1;
}

.ptoc-mobile-drawer.active .ptoc-mobile-content {
    transform: translateY(0);
}

.ptoc-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ptoc-border);
}

.ptoc-mobile-header span {
    font-weight: 600;
    font-size: 16px;
    color: var(--ptoc-text);
}

.ptoc-mobile-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ptoc-border);
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--ptoc-text);
    cursor: pointer;
    transition: var(--ptoc-transition);
}

.ptoc-mobile-close:hover {
    background: #d1d5db;
}

.ptoc-mobile-list {
    max-height: calc(70vh - 70px);
    overflow-y: auto;
    padding: 8px 0 env(safe-area-inset-bottom, 16px);
}

.ptoc-mobile-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ptoc-mobile-list a {
    display: block;
    padding: 14px 20px;
    color: var(--ptoc-text);
    text-decoration: none;
    font-size: 15px;
    border-bottom: 1px solid #f3f4f6;
    transition: var(--ptoc-transition);
}

.ptoc-mobile-list a:active {
    background: rgba(249, 115, 22, 0.1);
}

.ptoc-mobile-list .ptoc-level-3 a { padding-left: 36px; font-size: 14px; }
.ptoc-mobile-list .ptoc-level-4 a { padding-left: 52px; font-size: 14px; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1400px) {
    .ptoc-wrapper {
        --ptoc-width: 220px;
    }
}

@media (max-width: 1200px) {
    .ptoc-wrapper {
        display: none;
    }
    
    .ptoc-fab {
        display: flex;
    }
    
    .ptoc-mobile-drawer {
        display: block;
    }
}

/* Tablet landscape */
@media (min-width: 769px) and (max-width: 1200px) {
    .ptoc-wrapper:not(.ptoc-style-dots) {
        display: none;
    }
    
    .ptoc-wrapper.ptoc-style-dots {
        display: block;
    }
}

/* Animation */
@keyframes ptoc-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.ptoc-list li.active a {
    animation: ptoc-pulse 0.3s ease;
}

/* Print */
@media print {
    .ptoc-wrapper,
    .ptoc-fab,
    .ptoc-mobile-drawer {
        display: none !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --ptoc-bg: #1f2937;
        --ptoc-text: #f3f4f6;
        --ptoc-text-muted: #9ca3af;
        --ptoc-border: #374151;
    }
}
