@layer base, components, utilities;

@layer base {
    :root {
        --primary-color: #2563eb;
        --primary-hover: #1d4ed8;
        --secondary-color: #64748b;
        --bg-color: #f8fafc;
        --text-color: #1e293b;
        --card-bg: #ffffff;
        --border-color: #e2e8f0;
        --shadow-color: rgba(0, 0, 0, 0.1);
        --success-color: #10b981;
        --error-color: #ef4444;
        
        --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    }

    * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }

    body {
        font-family: var(--font-family);
        background-color: var(--bg-color);
        color: var(--text-color);
        line-height: 1.6;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        background-image: 
            radial-gradient(circle at 2px 2px, rgba(0,0,0,0.02) 1px, transparent 0);
        background-size: 24px 24px;
    }

    .container {
        max-width: 1000px;
        margin: 2rem auto;
        padding: 0 1.5rem;
        flex: 1;
        width: 100%;
    }
}

@layer components {
    .card {
        background: var(--card-bg);
        border-radius: 12px;
        padding: 1.5rem;
        border: 1px solid var(--border-color);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .shadow {
        box-shadow: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -1px var(--shadow-color);
    }

    .card:hover {
        box-shadow: 0 10px 15px -3px var(--shadow-color), 0 4px 6px -2px var(--shadow-color);
    }

    .btn {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1.5rem;
        border-radius: 8px;
        font-weight: 600;
        cursor: pointer;
        border: none;
        transition: all 0.2s;
        font-size: 1rem;
    }

    .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .btn-primary {
        background-color: var(--primary-color);
        color: white;
    }

    .btn-primary:hover:not(:disabled) {
        background-color: var(--primary-hover);
    }

    .btn-secondary {
        background-color: var(--secondary-color);
        color: white;
    }

    .button-group {
        display: flex;
        gap: 1rem;
        margin-top: 1.5rem;
    }

    /* Law Selection Grid Styles */
    .law-selection-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
        margin: 1.5rem 0;
    }

    .law-group {
        background: #f1f5f9;
        padding: 1rem;
        border-radius: 8px;
        border: 1px solid var(--border-color);
    }

    .law-group-title {
        font-weight: 700;
        color: var(--primary-color);
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
        border-bottom: 2px solid #e2e8f0;
        font-size: 1.1rem;
    }

    .law-options {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Custom Checkbox Styles */
    .checkbox-container {
        display: block;
        position: relative;
        padding-left: 35px;
        margin-bottom: 12px;
        cursor: pointer;
        font-size: 1rem;
        user-select: none;
    }

    .checkbox-container input {
        position: absolute;
        opacity: 0;
        cursor: pointer;
        height: 0;
        width: 0;
    }

    .checkmark {
        position: absolute;
        top: 0;
        left: 0;
        height: 22px;
        width: 22px;
        background-color: #fff;
        border: 2px solid #cbd5e1;
        border-radius: 4px;
        transition: all 0.2s;
    }

    .checkbox-container:hover input ~ .checkmark {
        border-color: var(--primary-color);
    }

    .checkbox-container input:checked ~ .checkmark {
        background-color: var(--primary-color);
        border-color: var(--primary-color);
    }

    .checkmark:after {
        content: "";
        position: absolute;
        display: none;
    }

    .checkbox-container input:checked ~ .checkmark:after {
        display: block;
    }

    .checkbox-container .checkmark:after {
        left: 7px;
        top: 3px;
        width: 5px;
        height: 10px;
        border: solid white;
        border-width: 0 3px 3px 0;
        transform: rotate(45deg);
    }

    .data-table-container {
        margin-top: 2rem;
        overflow-x: auto;
        background: white;
        border-radius: 12px;
        border: 1px solid var(--border-color);
    }

    table {
        width: 100%;
        border-collapse: collapse;
        text-align: left;
    }

    th {
        background-color: #f1f5f9;
        padding: 1rem;
        font-weight: 700;
        color: #475569;
        border-bottom: 2px solid var(--border-color);
    }

    td {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    tr:last-child td {
        border-bottom: none;
    }

    tr:hover td {
        background-color: #f8fafc;
    }

    .empty-state {
        padding: 4rem 2rem;
        text-align: center;
        color: var(--secondary-color);
    }

    .empty-icon {
        font-size: 3rem;
        display: block;
        margin-bottom: 1rem;
    }

    #status-message {
        padding: 1rem;
        border-radius: 8px;
        margin-top: 1rem;
        font-weight: 500;
    }

    .status-success {
        background-color: #dcfce7;
        color: #166534;
        border: 1px solid #bbf7d0;
    }

    .status-error {
        background-color: #fee2e2;
        color: #991b1b;
        border: 1px solid #fecaca;
    }

    .status-hidden {
        display: none;
    }
}

@layer utilities {
    .mt-4 { margin-top: 1rem; }
    .mb-4 { margin-bottom: 1rem; }
}

@container (max-width: 600px) {
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}
